feat: Centralize authentication redirects to middleware, remove client-side redirect logic, and refine logout process.
This commit is contained in:
@@ -9,10 +9,11 @@ function TokenSync() {
|
||||
const hasInitialized = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
// Never restore tokens if a logout is in progress
|
||||
// Never restore tokens if a logout is in progress or we're on the logout page
|
||||
const loggingOut = localStorage.getItem("isLoggingOut") === "true";
|
||||
const onLogoutPage = window.location.pathname === "/logout";
|
||||
|
||||
if (status === "authenticated" && session?.user && !loggingOut) {
|
||||
if (status === "authenticated" && session?.user && !loggingOut && !onLogoutPage) {
|
||||
const user = session.user as { accessToken?: string; refreshToken?: string };
|
||||
|
||||
// Only sync tokens from NextAuth to localStorage if:
|
||||
|
||||
Reference in New Issue
Block a user