From 4f05bc619b4c2cd8627b965326389bfaee6bf199 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 19 Feb 2024 09:51:10 +0000 Subject: [PATCH] Handle branding cookies with different tenant ids --- .../builder/src/pages/builder/auth/_layout.svelte | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/pages/builder/auth/_layout.svelte b/packages/builder/src/pages/builder/auth/_layout.svelte index f5484182e8..8902e9ac61 100644 --- a/packages/builder/src/pages/builder/auth/_layout.svelte +++ b/packages/builder/src/pages/builder/auth/_layout.svelte @@ -10,13 +10,18 @@ $redirect("../") } - if ($admin?.checklist?.branding) { + if ($admin.cloud && $admin?.checklist?.branding) { let url = new URL(window.location.href) let hostname = url.hostname let parts = hostname.split(".") - let tenantId = parts[0] + let newTenantId = parts[0] let domain = parts.slice(-2).join(".") - CookieUtils.setCookie("tenantId", tenantId, domain) + + let existingTenantId = CookieUtils.getCookie("tenantId") + + if (!existingTenantId || existingTenantId !== newTenantId) { + CookieUtils.setCookie("tenantId", newTenantId, domain) + } } if (