Skip to content

Commit

Permalink
feat: 토큰 예외처리 상태코드 추가, 예외 시 accessToken 제거 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
dladncks1217 committed Aug 16, 2023
1 parent 7183160 commit 9df7f96
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion frontend/src/api/interceptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ export const handleTokenError = async (error: AxiosError<ErrorResponseData>) =>
status === HTTP_STATUS_CODE.BAD_REQUEST &&
(data.code === ERROR_CODE.INVALID_ACCESS_TOKEN ||
data.code === ERROR_CODE.INVALID_REFRESH_TOKEN ||
data.code === ERROR_CODE.EXPIRED_REFRESH_TOKEN)
data.code === ERROR_CODE.EXPIRED_REFRESH_TOKEN ||
data.code === ERROR_CODE.INVALID_TOKEN_VALIDATE ||
data.code === ERROR_CODE.NULL_REFRESH_TOKEN)
) {
localStorage.removeItem(ACCESS_TOKEN_KEY);

throw new HTTPError(status, data.message, data.code);
}

Expand Down
2 changes: 2 additions & 0 deletions frontend/src/constants/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export const ERROR_CODE = {
INVALID_ACCESS_TOKEN: 9102,
EXPIRED_REFRESH_TOKEN: 9103,
EXPIRED_ACCESS_TOKEN: 9104,
INVALID_TOKEN_VALIDATE: 9105,
NULL_REFRESH_TOKEN: 9106,
} as const;

export const HTTP_ERROR_MESSAGE = {
Expand Down

0 comments on commit 9df7f96

Please sign in to comment.