From 648ff4ca75aa94d74cf554b2192d0a3005fda36a Mon Sep 17 00:00:00 2001 From: manus-admin Date: Tue, 6 Oct 2026 17:19:05 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20revenir=20=C3=A0=20la=20connexion=20loca?= =?UTF-8?q?le=20apr=C3=A8s=20d=C3=A9connexion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/lib/authRedirect.ts | 4 ++++ client/src/main.tsx | 5 +++-- server/authRedirect.test.ts | 9 +++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 client/src/lib/authRedirect.ts create mode 100644 server/authRedirect.test.ts diff --git a/client/src/lib/authRedirect.ts b/client/src/lib/authRedirect.ts new file mode 100644 index 0000000..f4909cd --- /dev/null +++ b/client/src/lib/authRedirect.ts @@ -0,0 +1,4 @@ +/** Les applications Itinova reviennent toujours à leur écran de connexion local. */ +export function applicationLoginPath(currentPathname: string): "/login" | null { + return currentPathname === "/login" ? null : "/login"; +} diff --git a/client/src/main.tsx b/client/src/main.tsx index 8adf6f5..2e90f43 100644 --- a/client/src/main.tsx +++ b/client/src/main.tsx @@ -5,7 +5,7 @@ import { httpBatchLink, TRPCClientError } from "@trpc/client"; import { createRoot } from "react-dom/client"; import superjson from "superjson"; import App from "./App"; -import { getLoginUrl } from "./const"; +import { applicationLoginPath } from "./lib/authRedirect"; import "./index.css"; const queryClient = new QueryClient(); @@ -18,7 +18,8 @@ const redirectToLoginIfUnauthorized = (error: unknown) => { if (!isUnauthorized) return; - window.location.href = getLoginUrl(); + const loginPath = applicationLoginPath(window.location.pathname); + if (loginPath) window.location.assign(loginPath); }; queryClient.getQueryCache().subscribe(event => { diff --git a/server/authRedirect.test.ts b/server/authRedirect.test.ts new file mode 100644 index 0000000..626bd00 --- /dev/null +++ b/server/authRedirect.test.ts @@ -0,0 +1,9 @@ +import { describe, expect, it } from "vitest"; +import { applicationLoginPath } from "../client/src/lib/authRedirect"; + +describe("redirection après déconnexion", () => { + it("revient à la connexion locale et jamais au portail Manus", () => { + expect(applicationLoginPath("/veille")).toBe("/login"); + expect(applicationLoginPath("/login")).toBeNull(); + }); +});