Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 토큰 예외처리 상태코드 추가, 예외 시 accessToken 제거 로직 추가 #475

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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