From b6be98fa4e00aba9acab377d474588f5d536719d Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 29 Mar 2023 14:22:07 +0100 Subject: [PATCH] Making logic around logout very explicit. --- packages/builder/src/pages/builder/_layout.svelte | 7 ++----- packages/builder/src/stores/portal/tenants.js | 3 +++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/pages/builder/_layout.svelte b/packages/builder/src/pages/builder/_layout.svelte index 73e2f2f5f1..010f1db5eb 100644 --- a/packages/builder/src/pages/builder/_layout.svelte +++ b/packages/builder/src/pages/builder/_layout.svelte @@ -42,12 +42,9 @@ } // check if real tenant - const info = await tenants.info(urlTenantId) - if (!info.exists) { - return - } + const { exists: tenantExists } = await tenants.info(urlTenantId) - if (urlTenantId && user.tenantId !== urlTenantId) { + if (tenantExists && user.tenantId !== urlTenantId) { // user should not be here - play it safe and log them out try { await auth.logout() diff --git a/packages/builder/src/stores/portal/tenants.js b/packages/builder/src/stores/portal/tenants.js index 5820d26752..e93b48b144 100644 --- a/packages/builder/src/stores/portal/tenants.js +++ b/packages/builder/src/stores/portal/tenants.js @@ -6,6 +6,9 @@ export function tenantsStore() { return { info: async tenantId => { + if (!tenantId) { + return { exists: false } + } const contents = get(store) const found = contents.tenantInfo[tenantId] if (found) {