From e224455deaa52d18731be3577b6eb1561906d47a Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Fri, 8 May 2026 11:08:22 +0900 Subject: [PATCH] =?UTF-8?q?260508=5F09=5FENH:=20=EC=83=88=EB=A1=9C?= =?UTF-8?q?=EA=B3=A0=EC=B9=A8=20=EC=8B=9C=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=ED=92=80=EB=A6=AC=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useAuth.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/hooks/useAuth.ts b/src/hooks/useAuth.ts index 9bdb422..dbdf8dc 100644 --- a/src/hooks/useAuth.ts +++ b/src/hooks/useAuth.ts @@ -7,14 +7,29 @@ import type { LoginUser } from "@/types/auth"; import { getLocalStorage } from "@/store/storage/secure-storage"; import { StorageKeys } from "@/store/storage/storage-keys"; +const isAuthDebugEnabled = () => + typeof window !== "undefined" && localStorage.getItem("kfpa:debugAuth") === "1"; + export const useAuth = () => { const [auth, setAuth] = useAtom(authStateAtom); useEffect(() => { + if (isAuthDebugEnabled()) { + console.log("[auth] current atom state", auth); + console.log("[auth] raw storage value", localStorage.getItem(StorageKeys.AuthState)); + } + if (auth.user != null) return; const stored = getLocalStorage(StorageKeys.AuthState) as AuthState | null; + if (isAuthDebugEnabled()) { + console.log("[auth] parsed storage value", stored); + } + if (stored?.user != null) { + if (isAuthDebugEnabled()) { + console.log("[auth] restoring user from storage", stored.user); + } setAuth(stored); } }, [auth.user, setAuth]);