ФУНКЦИИ - NODEDC LAUNCHER: sync logout across tabs
This commit is contained in:
+17
-1
@@ -42,6 +42,7 @@ import {
|
||||
type LauncherAuthApp,
|
||||
} from "../shared/api/authApi";
|
||||
import { updateOwnPassword, updateOwnProfile } from "../shared/api/profileApi";
|
||||
import { subscribeToNodeDCLogoutEvents } from "../shared/session/sessionSync";
|
||||
import { loadPersistedLauncherData } from "../shared/api/storageApi";
|
||||
import {
|
||||
AdminOverlay,
|
||||
@@ -190,6 +191,17 @@ export function LauncherApp() {
|
||||
window.location.replace(buildLoginRedirectUrl(authSession.loginUrl));
|
||||
}, [authSession]);
|
||||
|
||||
useEffect(() => {
|
||||
let isRedirecting = false;
|
||||
|
||||
return subscribeToNodeDCLogoutEvents(() => {
|
||||
if (isRedirecting) return;
|
||||
|
||||
isRedirecting = true;
|
||||
window.location.replace(buildLoginRedirectUrl("/auth/login?prompt=login"));
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
let isMounted = true;
|
||||
|
||||
@@ -511,6 +523,10 @@ export function LauncherApp() {
|
||||
return null;
|
||||
}
|
||||
|
||||
const handleLogout = () => {
|
||||
window.location.replace(authSession.logoutUrl);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="launcher-app">
|
||||
<TopBar
|
||||
@@ -525,7 +541,7 @@ export function LauncherApp() {
|
||||
onToggleAdmin={() => setAdminOpen((current) => !current)}
|
||||
onOpenShowcase={() => setAdminOpen(false)}
|
||||
onOpenProfileSettings={() => setProfileSettingsOpen(true)}
|
||||
onLogout={() => window.location.replace(authSession.logoutUrl)}
|
||||
onLogout={handleLogout}
|
||||
/>
|
||||
|
||||
<main className="launcher-main">
|
||||
|
||||
Reference in New Issue
Block a user