ФУНКЦИИ - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: Plane live access и logout handoff

This commit is contained in:
DCCONSTRUCTIONS
2026-05-04 18:54:21 +03:00
parent 55318f14e5
commit 3b13e5be52
15 changed files with 435 additions and 36 deletions
@@ -12,6 +12,7 @@ import useSWR from "swr";
import { LogoSpinner } from "@/components/common/logo-spinner";
// helpers
import { EPageTypes } from "@/helpers/authentication.helper";
import { buildNodeDCOIDCLoginUrl, getCurrentRelativePath, shouldUseNodeDCOIDC } from "@/helpers/nodedc-auth";
// hooks
import { useWorkspace } from "@/hooks/store/use-workspace";
import { useUser, useUserProfile, useUserSettings } from "@/hooks/store/user";
@@ -82,6 +83,15 @@ export const AuthenticationWrapper = observer(function AuthenticationWrapper(pro
return redirectionRoute;
};
const redirectToPlatformLogin = () => {
if (shouldUseNodeDCOIDC()) {
window.location.replace(buildNodeDCOIDCLoginUrl(getCurrentRelativePath()));
return;
}
router.push(`/${pathname ? `?next_path=${pathname}` : ``}`);
};
if ((isUserSWRLoading || isUserLoading || workspacesLoader) && !currentUser?.id)
return (
<div className="relative flex h-screen w-full items-center justify-center">
@@ -107,7 +117,7 @@ export const AuthenticationWrapper = observer(function AuthenticationWrapper(pro
if (pageType === EPageTypes.ONBOARDING) {
if (!currentUser?.id) {
router.push(`/${pathname ? `?next_path=${pathname}` : ``}`);
redirectToPlatformLogin();
return <></>;
} else {
if (currentUser && currentUserProfile?.id && isUserOnboard) {
@@ -120,7 +130,7 @@ export const AuthenticationWrapper = observer(function AuthenticationWrapper(pro
if (pageType === EPageTypes.SET_PASSWORD) {
if (!currentUser?.id) {
router.push(`/${pathname ? `?next_path=${pathname}` : ``}`);
redirectToPlatformLogin();
return <></>;
} else {
if (currentUser && !currentUser?.is_password_autoset && currentUserProfile?.id && isUserOnboard) {
@@ -139,7 +149,7 @@ export const AuthenticationWrapper = observer(function AuthenticationWrapper(pro
return <></>;
}
} else {
router.push(`/${pathname ? `?next_path=${pathname}` : ``}`);
redirectToPlatformLogin();
return <></>;
}
}