ФУНКЦИИ - NODEDC LAUNCHER: fix global logout handoff
This commit is contained in:
+33
-1
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user