fix: revenir à la connexion locale après déconnexion
This commit is contained in:
4
client/src/lib/authRedirect.ts
Normal file
4
client/src/lib/authRedirect.ts
Normal 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";
|
||||||
|
}
|
||||||
@@ -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 => {
|
||||||
|
|||||||
9
server/authRedirect.test.ts
Normal file
9
server/authRedirect.test.ts
Normal 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();
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user