Skip to content

Commit

Permalink
Merge pull request #222 from SystemConsultantGroup/fix/login-error-patch
Browse files Browse the repository at this point in the history
[FIX] access token과 db가 담고있는 정보의 차이 시 무한 로딩 문제 해결 시도
  • Loading branch information
shj1081 authored Feb 11, 2025
2 parents 7099b86 + d4d21f9 commit 488ebae
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/common/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useAuth } from "../Auth";

export function Header() {
const [isOpen, setIsOpen] = useState(false);
const { isLoggedIn } = useAuth();
const { isLoggedIn, logout } = useAuth(); // Destructure logout here
const router = useRouter();
const pathname = usePathname(); // 현재 경로 가져오기

Expand All @@ -28,6 +28,11 @@ export function Header() {
if (error.response?.data?.code === 4001) {
router.push("/register");
}

// 예: code 4002이 응답되면 로그아웃 수행
if (error.response?.data?.code === 4002) {
logout();
}
});
}
}, [isLoggedIn, router, pathname]);
Expand Down

0 comments on commit 488ebae

Please sign in to comment.