690331:1616 Correspondence Page Refactor by GPT-5.3-Codex Medium #03
CI / CD Pipeline / build (push) Successful in 15m34s
CI / CD Pipeline / deploy (push) Successful in 6m11s

This commit is contained in:
2026-03-31 16:16:12 +07:00
parent 156c28f49e
commit bf5c67fc7e
4 changed files with 60 additions and 28 deletions
+3
View File
@@ -3,6 +3,7 @@
import { useSession, signOut } from 'next-auth/react';
import { useEffect } from 'react';
import { useAuthStore } from '@/lib/stores/auth-store';
import { clearAuthTokenCache } from '@/lib/api/client';
export function AuthSync() {
const { data: session, status } = useSession();
@@ -10,6 +11,7 @@ export function AuthSync() {
useEffect(() => {
if (session?.error === 'RefreshAccessTokenError') {
clearAuthTokenCache(); // Clear cached token on auth error
signOut({ callbackUrl: '/login' });
} else if (status === 'authenticated' && session?.user) {
// Map NextAuth session to AuthStore user
@@ -40,6 +42,7 @@ export function AuthSync() {
(session as { accessToken?: string }).accessToken || ''
);
} else if (status === 'unauthenticated') {
clearAuthTokenCache(); // Clear cached token on logout
logout();
}
}, [session, status, setAuth, logout]);