Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.writon.admin.global.config.auth;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.writon.admin.global.error.ErrorCode;
import com.writon.admin.global.error.ExceptionResponseHandler;
import jakarta.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -38,8 +37,8 @@ public void commence(
errorCode = ErrorCode.REFRESH_TOKEN_EXPIRATION;
}

if (exception.equals(ErrorCode.UNAUTHORIZED_TOKEN.getCode())) {
errorCode = ErrorCode.UNAUTHORIZED_TOKEN;
if (exception.equals(ErrorCode.NOT_CORRECT_USER.getCode())) {
errorCode = ErrorCode.NOT_CORRECT_USER;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ public boolean validateToken(String token, HttpServletRequest request) {
} catch (UnsupportedJwtException e) {
log.info("지원되지 않는 JWT 토큰입니다.");
} catch (IllegalArgumentException e) {
log.info("JWT 토큰이 잘못되었습니다.");
request.setAttribute("exception", ErrorCode.UNAUTHORIZED_TOKEN.getCode());
log.info("아이디나 비밀번호가 잘못되었습니다");
request.setAttribute("exception", ErrorCode.NOT_CORRECT_USER.getCode());
}
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/writon/admin/global/error/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public enum ErrorCode {

// error
BAD_REQUEST(HttpStatus.BAD_REQUEST, "400", "잘못된 요청입니다"), // 400 Bad Request
UNAUTHORIZED(HttpStatus.UNAUTHORIZED, "401", "권한이 없습니다"), // 400 Bad Request
UNAUTHORIZED(HttpStatus.UNAUTHORIZED, "401", "권한이 없습니다"), // 401 Unauthorized
FORBIDDEN(HttpStatus.FORBIDDEN, "403", "잘못된 요청입니다"), // 403 Forbidden
NOT_FOUND(HttpStatus.NOT_FOUND, "404", "사용자를 찾을 수 없습니다"), // 404 Not Found
METHOD_NOT_ALLOWED(HttpStatus.METHOD_NOT_ALLOWED, "405", "허용되지 않은 메소드입니다"), // 405 Method Not Allowed
Expand All @@ -21,7 +21,7 @@ public enum ErrorCode {

// auth
USER_NOT_FOUND(HttpStatus.NOT_FOUND, "A01", "사용자를 찾을 수 없습니다"),
UNAUTHORIZED_TOKEN(HttpStatus.UNAUTHORIZED, "A02", "권한이 없는 토큰입니다"),
NOT_CORRECT_USER(HttpStatus.BAD_REQUEST, "A02", "아이디나 비밀번호가 잘못되었습니다"),
REFRESH_TOKEN_EXPIRATION(HttpStatus.UNAUTHORIZED, "A03", "만료된 토큰입니다"),
ACCESS_TOKEN_EXPIRATION(HttpStatus.UNAUTHORIZED, "A04", "토큰 재발급을 요청해주세요"),
REFRESH_TOKEN_INCONSISTENCY(HttpStatus.NOT_FOUND, "A05", "토큰이 일치하지 않습니다"),
Expand Down