ФУНКЦИИ - NODEDC LAUNCHER: fix global logout handoff

This commit is contained in:
DCCONSTRUCTIONS
2026-05-04 22:22:08 +03:00
parent 8e6d2cea39
commit ab1e0856d6
2 changed files with 71 additions and 6 deletions
+33 -1
View File
@@ -190,6 +190,38 @@ export function LauncherApp() {
window.location.replace(buildLoginRedirectUrl(authSession.loginUrl));
}, [authSession]);
useEffect(() => {
let isMounted = true;
const validateRestoredSession = (event: PageTransitionEvent) => {
if (!event.persisted) return;
fetchAuthSession()
.then((session) => {
if (!isMounted) return;
if (!session.authenticated) {
window.location.replace(buildLoginRedirectUrl(session.loginUrl));
return;
}
setAuthSession(session);
})
.catch(() => {
if (isMounted) {
window.location.replace(buildLoginRedirectUrl("/auth/login"));
}
});
};
window.addEventListener("pageshow", validateRestoredSession);
return () => {
isMounted = false;
window.removeEventListener("pageshow", validateRestoredSession);
};
}, []);
useEffect(() => {
if (!authSession?.authenticated) return;
@@ -493,7 +525,7 @@ export function LauncherApp() {
onToggleAdmin={() => setAdminOpen((current) => !current)}
onOpenShowcase={() => setAdminOpen(false)}
onOpenProfileSettings={() => setProfileSettingsOpen(true)}
onLogout={() => window.location.assign(authSession.logoutUrl)}
onLogout={() => window.location.replace(authSession.logoutUrl)}
/>
<main className="launcher-main">