From d04aa25d050abe3bc0b97f383a77e33f155794e3 Mon Sep 17 00:00:00 2001 From: jungwoo3490 Date: Mon, 12 Aug 2024 21:03:42 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C?= =?UTF-8?q?=20=EC=8A=A4=ED=86=A0=EB=A6=AC=EC=A7=80=20=EC=A0=80=EC=9E=A5=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Login/page/index.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Login/page/index.tsx b/src/Login/page/index.tsx index 6938af2e..2e3e27bd 100644 --- a/src/Login/page/index.tsx +++ b/src/Login/page/index.tsx @@ -5,9 +5,6 @@ import LoginBtnContainer from '../components/LoginBtnContainer'; import * as S from './Login.style'; function Login() { - const ref = document.referrer; - sessionStorage.setItem('url', ref); - return (
From 1dc382d4e12e5e2746d2da67b45ac94ace79699b Mon Sep 17 00:00:00 2001 From: jungwoo3490 Date: Mon, 12 Aug 2024 21:20:18 +0900 Subject: [PATCH 2/2] fix: resolve 401 error --- src/Login/hooks/usePostLoginToken.ts | 2 +- src/Register/api/patchNickname.ts | 3 ++- src/Register/hooks/usePatchNickname.ts | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Login/hooks/usePostLoginToken.ts b/src/Login/hooks/usePostLoginToken.ts index 9a4b9032..872d8805 100644 --- a/src/Login/hooks/usePostLoginToken.ts +++ b/src/Login/hooks/usePostLoginToken.ts @@ -14,7 +14,7 @@ const usePostLoginToken = () => { const { tokenDto, nickname } = data; if (nickname === null) { - navigate('/register', { state: tokenDto.accessToken }); + navigate('/register', { state: { tempToken: tokenDto.accessToken } }); } else { sessionStorage.setItem('token', tokenDto.accessToken); sessionStorage.setItem('nickname', nickname); diff --git a/src/Register/api/patchNickname.ts b/src/Register/api/patchNickname.ts index ca9ae120..3406fc16 100644 --- a/src/Register/api/patchNickname.ts +++ b/src/Register/api/patchNickname.ts @@ -1,12 +1,13 @@ import { api } from '../../libs/api'; -export const patchNickname = async (nickname: string) => { +export const patchNickname = async (nickname: string, tempToken: string) => { const response = await api().patch( '/api/nickname', { nickname: nickname }, { headers: { 'Content-Type': 'application/json', + Authorization: `Bearer ${tempToken}`, }, }, ); diff --git a/src/Register/hooks/usePatchNickname.ts b/src/Register/hooks/usePatchNickname.ts index c97587e7..f27fcc68 100644 --- a/src/Register/hooks/usePatchNickname.ts +++ b/src/Register/hooks/usePatchNickname.ts @@ -11,12 +11,13 @@ import { const usePatchNickname = (props: usePatchNicknameProps) => { const { handleSetIsValid, handleSetIsActive, nickname } = props; const { state } = useLocation(); + const tempToken = state.tempToken; const navigate = useNavigate(); const mutation = useMutation({ mutationFn: async ({ nickname }: patchNicknameProps) => { - return await patchNickname(nickname); + return await patchNickname(nickname, tempToken); }, onError: (err: AxiosError) => { const code = err.response?.status; @@ -32,7 +33,7 @@ const usePatchNickname = (props: usePatchNicknameProps) => { } }, onSuccess: () => { - sessionStorage.setItem('token', state); + sessionStorage.setItem('token', state.tempToken); sessionStorage.setItem('nickname', nickname); navigate('/', { state: { step: 1 } }); },