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:
parent
21b38e7297
commit
f9767191e8
|
|
@ -339,6 +339,20 @@ export function renderSpaceDashboard(space: string, modules: ModuleInfo[]): stri
|
||||||
import '/shell.js';
|
import '/shell.js';
|
||||||
document.querySelector('rstack-app-switcher')?.setModules(${moduleListJSON});
|
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
|
// Fix up dashboard links to be subdomain-aware
|
||||||
if (window.__rspaceNavUrl) {
|
if (window.__rspaceNavUrl) {
|
||||||
document.querySelectorAll('.sd-card[data-module]').forEach(card => {
|
document.querySelectorAll('.sd-card[data-module]').forEach(card => {
|
||||||
|
|
|
||||||
|
|
@ -401,6 +401,8 @@ export class RStackIdentity extends HTMLElement {
|
||||||
this.#render();
|
this.#render();
|
||||||
if (e.key === "encryptid_session") {
|
if (e.key === "encryptid_session") {
|
||||||
this.dispatchEvent(new CustomEvent("auth-change", { bubbles: true, composed: true }));
|
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") {
|
if (action === "signout") {
|
||||||
clearSession();
|
clearSession();
|
||||||
resetDocBridge();
|
resetDocBridge();
|
||||||
this.#render();
|
|
||||||
this.dispatchEvent(new CustomEvent("auth-change", { bubbles: true, composed: true }));
|
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") {
|
} else if (action === "my-account") {
|
||||||
this.showAccountModal();
|
this.showAccountModal();
|
||||||
} else if (action === "my-spaces") {
|
} else if (action === "my-spaces") {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue