feat: Introduce Nginx development configuration and enhance authentication state management by refining logout flag handling and session restoration conditions.
This commit is contained in:
@@ -9,11 +9,13 @@ function TokenSync() {
|
||||
const hasInitialized = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
// Never restore tokens if a logout is in progress or we're on the logout page
|
||||
// Never restore tokens if a logout is in progress or we're on auth/logout pages
|
||||
const loggingOut = localStorage.getItem("isLoggingOut") === "true";
|
||||
const onLogoutPage = window.location.pathname === "/logout";
|
||||
const path = window.location.pathname;
|
||||
const onAuthPage = path === "/login" || path === "/signup" || path === "/logout"
|
||||
|| path.startsWith("/forgot-password") || path.startsWith("/reset-password");
|
||||
|
||||
if (status === "authenticated" && session?.user && !loggingOut && !onLogoutPage) {
|
||||
if (status === "authenticated" && session?.user && !loggingOut && !onAuthPage) {
|
||||
const user = session.user as { accessToken?: string; refreshToken?: string };
|
||||
|
||||
// Only sync tokens from NextAuth to localStorage if:
|
||||
|
||||
Reference in New Issue
Block a user