From 421c0d33c16877087e82909993921c4dccced6b8 Mon Sep 17 00:00:00 2001 From: SeongMin Kim <86355699+Collection50@users.noreply.github.com> Date: Sun, 8 Sep 2024 00:25:29 +0900 Subject: [PATCH] =?UTF-8?q?fix(login):=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?(#82)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix * fix * fix --- src/app/AuthRedirect.tsx | 16 +++++++++------- src/app/login/page.tsx | 5 ++--- 2 files changed, 11 insertions(+), 10 deletions(-) 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 ( - +