diff --git a/web-admin/src/routes/[organization]/[project]/+layout.svelte b/web-admin/src/routes/[organization]/[project]/+layout.svelte index 38d0cc8531a..b26ae8f2104 100644 --- a/web-admin/src/routes/[organization]/[project]/+layout.svelte +++ b/web-admin/src/routes/[organization]/[project]/+layout.svelte @@ -2,6 +2,8 @@ import { goto } from "$app/navigation"; import { page } from "$app/stores"; import RuntimeProvider from "@rilldata/web-common/runtime-client/RuntimeProvider.svelte"; + import { createAdminServiceGetDeploymentCredentials } from "../../../client"; + import { viewAsUserStore } from "../../../components/authentication/viewAsUserStore"; import { useProjectRuntime } from "../../../components/projects/selectors"; $: projRuntime = useProjectRuntime( @@ -15,13 +17,27 @@ // Redirect any nested routes (notably dashboards) to the project page goto(`/${$page.params.organization}/${$page.params.project}`); } + + // if viewAs is set (which only admins can configure), we need to update the runtime with the new jwt + $: deploymentCredsQuery = createAdminServiceGetDeploymentCredentials( + $page.params.organization, + $page.params.project, + { + userId: $viewAsUserStore?.id, + }, + { + query: { + enabled: $viewAsUserStore?.id !== undefined, + }, + } + ); {#if $projRuntime.data}