From f9767191e88298b10c711f493a709cb2ed6683e7 Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Tue, 24 Mar 2026 10:54:35 -0700 Subject: [PATCH] fix(auth): reload page on logout and redirect logged-in users from space grid After logout, reload the page so the server re-renders the current rApp in logged-out/demo mode instead of showing a blank screen. Cross-tab logout also triggers a reload. Space dashboard now redirects logged-in users to the rSpace canvas instead of showing the rApp grid. Co-Authored-By: Claude Opus 4.6 --- server/landing.ts | 14 ++++++++++++++ shared/components/rstack-identity.ts | 6 +++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/server/landing.ts b/server/landing.ts index 0046f41..96574a1 100644 --- a/server/landing.ts +++ b/server/landing.ts @@ -339,6 +339,20 @@ export function renderSpaceDashboard(space: string, modules: ModuleInfo[]): stri import '/shell.js'; document.querySelector('rstack-app-switcher')?.setModules(${moduleListJSON}); + // Logged-in users: redirect to rSpace canvas instead of showing the grid + try { + var raw = localStorage.getItem('encryptid_session'); + if (raw) { + var session = JSON.parse(raw); + if (session?.accessToken) { + var dest = window.__rspaceNavUrl + ? window.__rspaceNavUrl('${escapeAttr(space)}', 'rspace') + : '/${escapeAttr(space)}/rspace'; + window.location.replace(dest); + } + } + } catch(e) {} + // Fix up dashboard links to be subdomain-aware if (window.__rspaceNavUrl) { document.querySelectorAll('.sd-card[data-module]').forEach(card => { diff --git a/shared/components/rstack-identity.ts b/shared/components/rstack-identity.ts index bf2c630..26c3c2f 100644 --- a/shared/components/rstack-identity.ts +++ b/shared/components/rstack-identity.ts @@ -401,6 +401,8 @@ export class RStackIdentity extends HTMLElement { this.#render(); if (e.key === "encryptid_session") { this.dispatchEvent(new CustomEvent("auth-change", { bubbles: true, composed: true })); + // Session cleared from another tab — reload to show logged-out state + if (!e.newValue) window.location.reload(); } } }; @@ -534,8 +536,10 @@ export class RStackIdentity extends HTMLElement { if (action === "signout") { clearSession(); resetDocBridge(); - this.#render(); this.dispatchEvent(new CustomEvent("auth-change", { bubbles: true, composed: true })); + // Reload so the server re-renders the current rApp in logged-out mode + window.location.reload(); + return; } else if (action === "my-account") { this.showAccountModal(); } else if (action === "my-spaces") {