From d504e46c5899a3bf18ebf91aec970d954a6aa556 Mon Sep 17 00:00:00 2001 From: hl3470 Date: Mon, 12 Aug 2024 21:45:14 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20402=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/common/exception/errorCode/UserErrorCode.java | 3 ++- .../common/security/jwt/filter/JwtAuthenticationFilter.java | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/middle_point_search/backend/common/exception/errorCode/UserErrorCode.java b/backend/src/main/java/middle_point_search/backend/common/exception/errorCode/UserErrorCode.java index 6515817..738a135 100644 --- a/backend/src/main/java/middle_point_search/backend/common/exception/errorCode/UserErrorCode.java +++ b/backend/src/main/java/middle_point_search/backend/common/exception/errorCode/UserErrorCode.java @@ -9,8 +9,9 @@ public enum UserErrorCode implements ErrorCode { //4xx UNAUTHORIZED(HttpStatus.UNAUTHORIZED, "인증에 실패하였습니다."), - INVALID_ACCESS_TOKEN(HttpStatus.PAYMENT_REQUIRED, "Access Token이 유효하지 않습니다."), + INVALID_ACCESS_TOKEN(HttpStatus.UNAUTHORIZED, "Access Token이 유효하지 않습니다."), INVALID_REFRESH_TOKEN(HttpStatus.UNAUTHORIZED, "Refresh Token이 유효하지 않습니다."), + REISSUE_ACCESS_TOKEN(HttpStatus.PAYMENT_REQUIRED, "Access Token을 재발급해야합니다."), ACCESS_DENIED(HttpStatus.FORBIDDEN, "접근 권한이 없습니다."), MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "존재하지 않는 회원입니다."), diff --git a/backend/src/main/java/middle_point_search/backend/common/security/jwt/filter/JwtAuthenticationFilter.java b/backend/src/main/java/middle_point_search/backend/common/security/jwt/filter/JwtAuthenticationFilter.java index e5dae8f..48cdf37 100644 --- a/backend/src/main/java/middle_point_search/backend/common/security/jwt/filter/JwtAuthenticationFilter.java +++ b/backend/src/main/java/middle_point_search/backend/common/security/jwt/filter/JwtAuthenticationFilter.java @@ -6,7 +6,6 @@ import java.io.IOException; import java.util.Arrays; import java.util.Objects; -import java.util.Optional; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContext; @@ -21,7 +20,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import middle_point_search.backend.common.exception.CustomException; -import middle_point_search.backend.common.exception.errorCode.UserErrorCode; import middle_point_search.backend.common.properties.SecurityProperties; import middle_point_search.backend.common.security.jwt.provider.JwtTokenProvider; import middle_point_search.backend.domains.member.repository.MemberRepository; @@ -102,7 +100,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse filterChain.doFilter(request, response); } else if (accessToken != null && !jwtTokenProvider.isTokenValid(accessToken)) { log.info("access토큰 인증 실패"); - throw new CustomException(INVALID_ACCESS_TOKEN); + throw new CustomException(REISSUE_ACCESS_TOKEN); } else if (refreshToken != null && jwtTokenProvider.isTokenValid(refreshToken)) { log.info("refresh토큰 인증 성공"); jwtTokenProvider.checkRefreshTokenAndReIssueAccessAndRefreshToken(response, refreshToken);