ФУНКЦИИ - NODEDC LAUNCHER: sync logout across tabs

This commit is contained in:
DCCONSTRUCTIONS
2026-05-04 23:23:40 +03:00
parent 316bb0a1df
commit 049b914916
3 changed files with 219 additions and 1 deletions
+17 -1
View File
@@ -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">