Skip to content

Commit 0401d38

Browse files
authored
Merge pull request #33 from new-writon/32-로그인-에러-1차-해결
fix: 로그인 에러 1차 수정
2 parents 101da8b + d878a33 commit 0401d38

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/main/java/com/writon/admin/global/config/auth/JwtAuthenticationEntryPoint.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.writon.admin.global.config.auth;
22

3-
import com.fasterxml.jackson.databind.ObjectMapper;
43
import com.writon.admin.global.error.ErrorCode;
54
import com.writon.admin.global.error.ExceptionResponseHandler;
65
import jakarta.servlet.http.HttpServletRequest;
@@ -38,8 +37,8 @@ public void commence(
3837
errorCode = ErrorCode.REFRESH_TOKEN_EXPIRATION;
3938
}
4039

41-
if (exception.equals(ErrorCode.UNAUTHORIZED_TOKEN.getCode())) {
42-
errorCode = ErrorCode.UNAUTHORIZED_TOKEN;
40+
if (exception.equals(ErrorCode.NOT_CORRECT_USER.getCode())) {
41+
errorCode = ErrorCode.NOT_CORRECT_USER;
4342
}
4443
}
4544

src/main/java/com/writon/admin/global/config/auth/TokenProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ public boolean validateToken(String token, HttpServletRequest request) {
139139
} catch (UnsupportedJwtException e) {
140140
log.info("지원되지 않는 JWT 토큰입니다.");
141141
} catch (IllegalArgumentException e) {
142-
log.info("JWT 토큰이 잘못되었습니다.");
143-
request.setAttribute("exception", ErrorCode.UNAUTHORIZED_TOKEN.getCode());
142+
log.info("아이디나 비밀번호가 잘못되었습니다");
143+
request.setAttribute("exception", ErrorCode.NOT_CORRECT_USER.getCode());
144144
}
145145
return false;
146146
}

src/main/java/com/writon/admin/global/error/ErrorCode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public enum ErrorCode {
1111

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

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

0 commit comments

Comments
 (0)