diff --git a/src/app/AuthRedirect.tsx b/src/app/AuthRedirect.tsx index 15932ca..3550e4b 100644 --- a/src/app/AuthRedirect.tsx +++ b/src/app/AuthRedirect.tsx @@ -1,16 +1,18 @@ -import { cookies } from 'next/headers'; +'use client'; + import { ACCESS_TOKEN, JOB_SELECTION, REFRESH_TOKEN } from './login/constants/token'; import { redirect } from 'next/navigation'; import type { StrictPropsWithChildren } from '@/types'; +import { deleteCookie, getCookie } from 'cookies-next'; -export default async function AuthRedirect({ children }: StrictPropsWithChildren) { - const accessToken = cookies().get(ACCESS_TOKEN)?.value; - const isJobSelection = cookies().get(JOB_SELECTION)?.value; +export default function AuthRedirect({ children }: StrictPropsWithChildren) { + const accessToken = getCookie(ACCESS_TOKEN) as string; + const isJobSelection = getCookie(JOB_SELECTION) as string; if (!accessToken || !isJobSelection) { - cookies().delete(ACCESS_TOKEN); - cookies().delete(REFRESH_TOKEN); - cookies().delete(JOB_SELECTION); + deleteCookie(ACCESS_TOKEN); + deleteCookie(REFRESH_TOKEN); + deleteCookie(JOB_SELECTION); redirect('/login'); } diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx index 52a3693..5c435d0 100644 --- a/src/app/login/page.tsx +++ b/src/app/login/page.tsx @@ -5,17 +5,16 @@ import { useFunnel } from '@/system/components/Funnel/useFunnel'; import { getCookie } from 'cookies-next'; import { Login } from './components/Login'; import Select from './components/Select'; -import { ACCESS_TOKEN, JOB_SELECTION, SELECT } from './constants/token'; +import { JOB_SELECTION, SELECT } from './constants/token'; export default function Page() { const Funnel = useFunnel(['login', 'select'] as const, { initialStep: 'login', stepQueryKey: 'auth' }); const isSelectJob = getCookie(JOB_SELECTION) === SELECT; - const accessToken = getCookie(ACCESS_TOKEN); return ( - +