From 04d70ee138ebdecd7ffedefde7e377caaff06883 Mon Sep 17 00:00:00 2001 From: hyesung99 <4538asd@gmail.com> Date: Fri, 1 Dec 2023 17:26:57 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=ED=86=A0=ED=81=B0=20=EB=A7=8C?= =?UTF-8?q?=EB=A3=8C=20=EC=98=88=EC=99=B8=20=EC=BD=94=EB=93=9C=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/interceptor.ts | 5 +++-- src/constants/exceptionCode.ts | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/apis/interceptor.ts b/src/apis/interceptor.ts index 74b0a588..1514818e 100644 --- a/src/apis/interceptor.ts +++ b/src/apis/interceptor.ts @@ -17,14 +17,15 @@ const handleTokenError = async (error: AxiosError) => { originalRequest.headers.Authorization = `Bearer ${refreshToken}`; - if (error.response?.data.code === EXCEPTION_CODE.INVALID_ACCESS_TOKEN) { + if (error.response?.data.code === EXCEPTION_CODE.EXPIRED_ACCESS_TOKEN) { return axiosClientWithAuth(originalRequest); } + return Promise.reject(error); }; const handleRefreshTokenError = (error: AxiosError) => { - if (error.response?.data.code === EXCEPTION_CODE.INVALID_REFRESH_TOKEN) { + if (error.response?.data.code === EXCEPTION_CODE.EXPIRED_REFRESH_TOKEN) { alert('로그인이 만료되었습니다. 다시 로그인해주세요.'); window.location.href = PATH.LOGIN; } diff --git a/src/constants/exceptionCode.ts b/src/constants/exceptionCode.ts index a94de6e8..f136958d 100644 --- a/src/constants/exceptionCode.ts +++ b/src/constants/exceptionCode.ts @@ -33,6 +33,8 @@ const EXCEPTION_CODE = { BAD_WORD_DETECTED: 'BAD_WORD_DETECTED', EXISTED_FORM: 'EXISTED_FORM', USER_CANNOT_WITHDRAW: 'USER_CANNOT_WITHDRAW', + EXPIRED_ACCESS_TOKEN: 'EXPIRED_ACCESS_TOKEN', + EXPIRED_REFRESH_TOKEN: 'EXPIRED_REFRESH_TOKEN', } as const; const EXCEPTION_CODE_MESSAGE: ExceptionCodeMessage = { @@ -68,6 +70,8 @@ const EXCEPTION_CODE_MESSAGE: ExceptionCodeMessage = { BAD_WORD_DETECTED: '비속어가 포함되어 있습니다.', EXISTED_FORM: '이미 폼 옵션을 설정한 행사입니다.', USER_CANNOT_WITHDRAW: '소속된 클럽을 모두 나간 뒤 탈퇴할 수 있습니다.', + EXPIRED_ACCESS_TOKEN: '만료된 토큰입니다.', + EXPIRED_REFRESH_TOKEN: '만료된 리프레시 토큰입니다.', }; export { EXCEPTION_CODE, EXCEPTION_CODE_MESSAGE };