fix(auth): redirect logged-out visitors from private spaces to module landing
Non-demo space dashboards now redirect logged-out visitors to
rspace.online/ instead of showing another user's rApp grid. Private
space module pages redirect to rspace.online/{moduleId} instead of
showing the sign-in gate overlay.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
fdf4db2050
commit
724c0e16ba
|
|
@ -340,15 +340,20 @@ export function renderSpaceDashboard(space: string, modules: ModuleInfo[]): stri
|
|||
document.querySelector('rstack-app-switcher')?.setModules(${moduleListJSON});
|
||||
|
||||
// Logged-in users: redirect to rSpace canvas instead of showing the grid
|
||||
// Non-demo spaces: redirect logged-out visitors to the main domain landing
|
||||
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);
|
||||
var loggedIn = raw && JSON.parse(raw)?.accessToken;
|
||||
if (loggedIn) {
|
||||
var dest = window.__rspaceNavUrl
|
||||
? window.__rspaceNavUrl('${escapeAttr(space)}', 'rspace')
|
||||
: '/${escapeAttr(space)}/rspace';
|
||||
window.location.replace(dest);
|
||||
} else if ('${escapeAttr(space)}' !== 'demo') {
|
||||
// Don't show other users' space dashboards to logged-out visitors
|
||||
var host = window.location.host.split(':')[0];
|
||||
if (host.endsWith('.rspace.online') || host === 'rspace.online') {
|
||||
window.location.replace('https://rspace.online/');
|
||||
}
|
||||
}
|
||||
} catch(e) {}
|
||||
|
|
|
|||
|
|
@ -636,8 +636,14 @@ export function renderShell(opts: ShellOptions): string {
|
|||
return;
|
||||
}
|
||||
|
||||
// Private spaces: need session + membership check
|
||||
// Private spaces: redirect logged-out visitors to the module landing page
|
||||
if (!hasToken) {
|
||||
var host = window.location.host.split(':')[0];
|
||||
if (host.endsWith('.rspace.online') || host === 'rspace.online') {
|
||||
var modId = document.body.getAttribute('data-module-id') || 'rspace';
|
||||
window.location.replace('https://rspace.online/' + modId);
|
||||
return;
|
||||
}
|
||||
showGate('sign-in');
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue