fix: improve page redirect handling for tenant sessions

- Refactored the page redirect logic to ensure proper session clearance for placeholder tenants.
- Added an asynchronous function to handle sign-out before redirecting to the target URL, with error logging for better debugging.

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2025-11-11 15:48:50 +08:00
parent 88f763d2e2
commit 5940558975

View File

@@ -163,7 +163,7 @@ export function usePageRedirect() {
return
}
const {tenant} = session
const { tenant } = session
if (!tenant || tenant.isPlaceholder || !tenant.slug) {
return
}
@@ -179,7 +179,15 @@ export function usePageRedirect() {
try {
const targetUrl = buildTenantUrl(tenant.slug, '/')
window.location.replace(targetUrl)
;(async () => {
try {
await signOutBySource()
} catch (error) {
console.error('Failed to clear placeholder session before redirect', error)
} finally {
window.location.replace(targetUrl)
}
})()
} catch (error) {
console.error('Failed to redirect to tenant workspace', error)
}