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); }