From 8c0b19d54278519d17d4cf8354aa8e932bd73ec3 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Fri, 8 May 2026 10:59:44 +0900 Subject: [PATCH] =?UTF-8?q?260508=5F07=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, 13 insertions(+), 2 deletions(-) diff --git a/src/hooks/useAuth.ts b/src/hooks/useAuth.ts index a11bd5d..9bdb422 100644 --- a/src/hooks/useAuth.ts +++ b/src/hooks/useAuth.ts @@ -1,13 +1,24 @@ "use client"; -import { useCallback } from "react"; +import { useCallback, useEffect } from "react"; import { useAtom } from "jotai"; import { authStateAtom, type AuthState } from "@/store/jotai/auth"; import type { LoginUser } from "@/types/auth"; +import { getLocalStorage } from "@/store/storage/secure-storage"; +import { StorageKeys } from "@/store/storage/storage-keys"; export const useAuth = () => { const [auth, setAuth] = useAtom(authStateAtom); + useEffect(() => { + if (auth.user != null) return; + + const stored = getLocalStorage(StorageKeys.AuthState) as AuthState | null; + if (stored?.user != null) { + setAuth(stored); + } + }, [auth.user, setAuth]); + // 로그인 성공 후 LoginResponse 를 바로 넣어줄 수 있게 const setFromLoginResponse = useCallback( (res: LoginUser) => { @@ -37,4 +48,4 @@ export const useAuth = () => { setFromLoginResponse, logout, }; -} \ No newline at end of file +}