From 87ef5392e1f1ad65a6ecf3dc20bee78073022df9 Mon Sep 17 00:00:00 2001 From: presentKey Date: Sun, 26 Nov 2023 21:47:57 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=ED=94=84=EB=A1=9C=EB=8D=95=EC=85=98?= =?UTF-8?q?=20=ED=99=98=EA=B2=BD=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EB=A5=BC=20?= =?UTF-8?q?=EC=9C=84=ED=95=9C=20=EC=BD=98=EC=86=94=20=EB=A1=9C=EA=B7=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/auth/contexts/AuthContext.tsx | 5 +++++ src/routes/privateRoutes.tsx | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/features/auth/contexts/AuthContext.tsx b/src/features/auth/contexts/AuthContext.tsx index a6052e84..2bc82313 100644 --- a/src/features/auth/contexts/AuthContext.tsx +++ b/src/features/auth/contexts/AuthContext.tsx @@ -42,10 +42,15 @@ export function AuthProvider({ children }: PropsWithChildren) { const fetchUser = useCallback(async () => { try { + console.log("AuthProvider fetchUser try"); const user = await authApi.getStatus(); + console.log(user); setUser(user); setAutoLogin(true); + console.log("AuthProvider fetchUser try end"); } catch (e) { + console.log("AuthProvider fetchUser 오류 발생"); + setUser(undefined); //FIXME: 배포환경 테스트를 위해 주석 처리 // removeAutoLogin(); diff --git a/src/routes/privateRoutes.tsx b/src/routes/privateRoutes.tsx index a938ef4b..1a7293e8 100644 --- a/src/routes/privateRoutes.tsx +++ b/src/routes/privateRoutes.tsx @@ -17,7 +17,11 @@ function PrivateRoute({ children }: PropsWithChildren) { * 유저 정보가 없다면 로그인 페이지로 이동합니다. */ useEffect(() => { + console.log("PrivateRoute user 정보"); + console.log(user); + if (!user) { + console.log("PrivateRoute: 로그인 페이지로 이동"); navigate("/login", { replace: true }); } }, [navigate, user]);