Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions js-packages/web-console/src/routes/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ const initAuth = async (): Promise<AuthInitResult> => {
onBeforeLogout() {
// Session-scoped data must not survive a logout/login cycle, since a different
// user may sign in on the same browser.
setSelectedTenant(undefined)
clearConfigCaches()
posthog.reset()
}
Expand Down Expand Up @@ -351,6 +352,8 @@ export const load: LayoutLoad = async (): Promise<LayoutData> => {
}
}

applyTenantSelection(computeAuthorizedTenants(auth))

const cachedConfig = OPTIMISTIC_CONFIG_CACHE ? getConfigFromCache() : undefined
const cachedSessionConfig = OPTIMISTIC_CONFIG_CACHE ? getSessionConfigFromCache() : undefined

Expand Down Expand Up @@ -430,17 +433,14 @@ function buildLayoutData(
/**
* Run side effects derived from `config` that are independent of server-time
* sync. Safe to call with cached config and safe to re-run: all pushes are
* deduped by id, tenant selection is idempotent for a stable auth, and
* `posthog.init` dedupes on its key.
* deduped by id and `posthog.init` dedupes on its key.
* It is expected to be idempotent - calling it the second time on lazy update
* when config hasn't changed should not break anything.
*
* Does NOT call `ServerDate.sync` — that belongs to `syncServerTimeFromConfig`,
* which only runs against freshly-fetched data.
*/
function initializeConfigDependencies(auth: AuthDetails, config: Configuration) {
applyTenantSelection(computeAuthorizedTenants(auth))

if (typeof auth === 'object' && 'logout' in auth) {
initPosthog(config).then(() => {
if (auth.profile.email) {
Expand Down
Loading