From a8a42819f1679df31041a8c91bffd36d0319127d Mon Sep 17 00:00:00 2001 From: yunjunghun0116 Date: Thu, 1 Aug 2024 10:11:57 +0900 Subject: [PATCH] =?UTF-8?q?remove:=20=EC=82=AC=EC=9A=A9=ED=95=98=EC=A7=80?= =?UTF-8?q?=20=EC=95=8A=EB=8A=94=20=EC=98=88=EC=99=B8=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 사용하지 않는 예외코드 삭제 --- .../gift/exception/GlobalExceptionHandler.java | 14 -------------- .../gift/exception/InvalidKakaoTokenException.java | 7 ------- src/main/java/gift/service/KakaoService.java | 3 +-- 3 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 src/main/java/gift/exception/InvalidKakaoTokenException.java diff --git a/src/main/java/gift/exception/GlobalExceptionHandler.java b/src/main/java/gift/exception/GlobalExceptionHandler.java index 9cf382977..d04613901 100644 --- a/src/main/java/gift/exception/GlobalExceptionHandler.java +++ b/src/main/java/gift/exception/GlobalExceptionHandler.java @@ -1,9 +1,7 @@ package gift.exception; import io.jsonwebtoken.ExpiredJwtException; -import org.springframework.beans.factory.annotation.Value; import org.springframework.data.mapping.PropertyReferenceException; -import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.validation.BindingResult; @@ -12,8 +10,6 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; -import java.net.URI; - @RestControllerAdvice public class GlobalExceptionHandler { @@ -24,8 +20,6 @@ public class GlobalExceptionHandler { private static final String INVALID_LOGIN_INFO_MESSAGE = "로그인 정보가 유효하지 않습니다."; private static final String INVALID_PAGE_REQUEST_MESSAGE = "요청에 담긴 페이지 정보가 유효하지 않습니다."; private static final String EXPIRED_JWT_MESSAGE = "인증 정보가 만료되었습니다."; - @Value("${kakao.redirect-token-uri}") - private String redirectTokenUri; @ExceptionHandler(value = NotFoundElementException.class) public ResponseEntity notFoundElementExceptionHandling() { @@ -62,14 +56,6 @@ public ResponseEntity expiredJwtExceptionHandling() { return getExceptionResponse(EXPIRED_JWT_MESSAGE, HttpStatus.UNAUTHORIZED); } - @ExceptionHandler(value = InvalidKakaoTokenException.class) - public ResponseEntity invalidKakaoTokenExceptionHandling() { - var headers = new HttpHeaders(); - String redirectLocation = redirectTokenUri; - headers.setLocation(URI.create(redirectLocation)); - return new ResponseEntity<>(headers, HttpStatus.MOVED_PERMANENTLY); - } - @ExceptionHandler(value = BadRequestException.class) public ResponseEntity badRequestExceptionHandling(BadRequestException exception) { return getExceptionResponse(exception.getMessage(), HttpStatus.BAD_REQUEST); diff --git a/src/main/java/gift/exception/InvalidKakaoTokenException.java b/src/main/java/gift/exception/InvalidKakaoTokenException.java deleted file mode 100644 index 67511aba9..000000000 --- a/src/main/java/gift/exception/InvalidKakaoTokenException.java +++ /dev/null @@ -1,7 +0,0 @@ -package gift.exception; - -public class InvalidKakaoTokenException extends RuntimeException { - public InvalidKakaoTokenException(String message) { - super(message); - } -} diff --git a/src/main/java/gift/service/KakaoService.java b/src/main/java/gift/service/KakaoService.java index db3e1d7da..4f7786384 100644 --- a/src/main/java/gift/service/KakaoService.java +++ b/src/main/java/gift/service/KakaoService.java @@ -5,7 +5,6 @@ import gift.dto.giftorder.GiftOrderResponse; import gift.dto.kakao.KakaoAuthInformation; import gift.dto.kakao.KakaoTokenResponse; -import gift.exception.InvalidKakaoTokenException; import gift.exception.NotFoundElementException; import gift.exception.UnauthorizedAccessException; import gift.model.Member; @@ -88,7 +87,7 @@ private OauthToken createAndSaveOauthToken(Member member, KakaoTokenResponse kak private OauthToken updateOauthToken(Member member, KakaoTokenResponse kakaoTokenResponse) { var kakaoToken = oauthTokenRepository.findByMemberIdAndOauthType(member.getId(), OauthType.KAKAO) - .orElseThrow(() -> new InvalidKakaoTokenException(member.getId() + "를 가진 이용자의 카카오 토큰 정보가 존재하지 않습니다.")); + .orElseThrow(() -> new NotFoundElementException(member.getId() + "를 가진 이용자의 카카오 토큰 정보가 존재하지 않습니다.")); kakaoToken.updateToken(kakaoTokenResponse.accessToken(), kakaoTokenResponse.accessTokenExpiresIn(), kakaoTokenResponse.refreshToken(), kakaoTokenResponse.refreshTokenExpiresIn()); return oauthTokenRepository.save(kakaoToken); }