fix: revenir à la connexion locale après déconnexion
All checks were successful
Deploy Production / deploy (push) Has been skipped
Deploy Recette / deploy (push) Successful in 1m29s
Validation applicative / TypeScript, tests et build (push) Successful in 2m44s

This commit is contained in:
manus-admin
2026-10-06 17:19:05 +02:00
parent ba34233189
commit 648ff4ca75
3 changed files with 16 additions and 2 deletions

View File

@@ -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";
}

View File

@@ -5,7 +5,7 @@ import { httpBatchLink, TRPCClientError } from "@trpc/client";
import { createRoot } from "react-dom/client"; import { createRoot } from "react-dom/client";
import superjson from "superjson"; import superjson from "superjson";
import App from "./App"; import App from "./App";
import { getLoginUrl } from "./const"; import { applicationLoginPath } from "./lib/authRedirect";
import "./index.css"; import "./index.css";
const queryClient = new QueryClient(); const queryClient = new QueryClient();
@@ -18,7 +18,8 @@ const redirectToLoginIfUnauthorized = (error: unknown) => {
if (!isUnauthorized) return; if (!isUnauthorized) return;
window.location.href = getLoginUrl(); const loginPath = applicationLoginPath(window.location.pathname);
if (loginPath) window.location.assign(loginPath);
}; };
queryClient.getQueryCache().subscribe(event => { queryClient.getQueryCache().subscribe(event => {

View File

@@ -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();
});
});