diff --git a/src/frontend/eyesee-admin/src/app/providers.tsx b/src/frontend/eyesee-admin/src/app/providers.tsx index feb41ee..fffb146 100644 --- a/src/frontend/eyesee-admin/src/app/providers.tsx +++ b/src/frontend/eyesee-admin/src/app/providers.tsx @@ -1,7 +1,9 @@ "use client"; +import { getAccessToken } from "@/utils/auth"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; -import { ReactNode } from "react"; +import { usePathname, useRouter } from "next/navigation"; +import { ReactNode, useEffect } from "react"; function makeQueryClient() { return new QueryClient({ @@ -32,6 +34,23 @@ type ProvidersProps = { export default function Providers({ children }: ProvidersProps) { const queryClient = getQueryClient(); + const accessToken = getAccessToken(); + + const pathname = usePathname(); + const router = useRouter(); + + // 로그인 여부를 검증하여 페이지 렌더링 + useEffect(() => { + if ( + !accessToken && + pathname != "/signin" && + pathname !== "/signup" && + pathname !== "/" + ) { + alert("로그인이 필요합니다."); + router.push("/signin"); + } + }, [pathname]); return ( {children}