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 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 => {
|
||||
|
||||
Reference in New Issue
Block a user