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 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2026-03-24 10:54:35 -07:00
parent 21b38e7297
commit f9767191e8
2 changed files with 19 additions and 1 deletions

View File

@ -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 => {

View File

@ -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") {