From c7b4830bd0ba62923134bda04be1571073953ef2 Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Fri, 4 Oct 2024 02:24:33 +0100 Subject: [PATCH] fix(frontend): logout redirection logic --- frontend/src/hooks/useAuth.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/hooks/useAuth.ts b/frontend/src/hooks/useAuth.ts index 2f8c7bf4..1f9fb0df 100755 --- a/frontend/src/hooks/useAuth.ts +++ b/frontend/src/hooks/useAuth.ts @@ -6,6 +6,7 @@ * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). */ +import { usePathname } from "next/navigation"; import { useRouter } from "next/router"; import { useContext } from "react"; @@ -32,11 +33,12 @@ export const useAuth = () => { export const useLogoutRedirection = () => { const router = useRouter(); + const pathname = usePathname(); const hasPublicPath = PUBLIC_PATHS.includes(router.pathname); const logoutRedirection = async (fullReload: boolean = false) => { if (!hasPublicPath) { const redirectUrl = `/${RouterType.LOGIN}?redirect=${encodeURIComponent( - router.pathname, + pathname, )}`; if (fullReload) {