diff --git a/6thSeminar/springPractice/src/main/java/org/sopt/springPractice/auth/redis/service/TokenService.java b/6thSeminar/springPractice/src/main/java/org/sopt/springPractice/auth/redis/service/TokenService.java index eb739ee..fe3f5e5 100644 --- a/6thSeminar/springPractice/src/main/java/org/sopt/springPractice/auth/redis/service/TokenService.java +++ b/6thSeminar/springPractice/src/main/java/org/sopt/springPractice/auth/redis/service/TokenService.java @@ -6,7 +6,6 @@ import org.sopt.springPractice.auth.redis.service.dto.AccessTokenDTO; import org.sopt.springPractice.common.dto.ErrorMessage; import org.sopt.springPractice.common.jwt.JwtTokenProvider; -import org.sopt.springPractice.common.jwt.JwtValidationType; import org.sopt.springPractice.exception.UnauthorizedException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -21,17 +20,10 @@ public class TokenService { @Transactional public AccessTokenDTO reissueAccessToken(Long userId) { Token token = redisTokenRepository.findById(userId).orElseThrow( - () -> new UnauthorizedException(ErrorMessage.REFRESH_TOKEN_NOT_FOUND) + () -> new UnauthorizedException(ErrorMessage.MEMBER_NOT_FOUND) ); - JwtValidationType validationType = jwtTokenProvider.validateToken(token.getRefreshToken()); - - if (validationType == JwtValidationType.EXPIRED_JWT_TOKEN) { - throw new UnauthorizedException(ErrorMessage.JWT_UNAUTHORIZED_EXCEPTION); - } else if (validationType != JwtValidationType.VALID_JWT) { - throw new UnauthorizedException(ErrorMessage.JWT_UNAUTHORIZED_EXCEPTION); - } - + jwtTokenProvider.validateToken(token.getRefreshToken()); String newAccessToken = jwtTokenProvider.newAccessToken(token.getRefreshToken()); return AccessTokenDTO.of(newAccessToken); diff --git a/6thSeminar/springPractice/src/main/java/org/sopt/springPractice/common/dto/ErrorMessage.java b/6thSeminar/springPractice/src/main/java/org/sopt/springPractice/common/dto/ErrorMessage.java index 032447c..a3989ec 100644 --- a/6thSeminar/springPractice/src/main/java/org/sopt/springPractice/common/dto/ErrorMessage.java +++ b/6thSeminar/springPractice/src/main/java/org/sopt/springPractice/common/dto/ErrorMessage.java @@ -11,7 +11,7 @@ public enum ErrorMessage { MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND.value(), "ID에 해당하는 사용자가 존재하지 않습니다."), BLOG_NOT_FOUND(HttpStatus.NOT_FOUND.value(), "ID에 해당하는 블로그가 존재하지 않습니다."), JWT_UNAUTHORIZED_EXCEPTION(HttpStatus.UNAUTHORIZED.value(), "사용자의 로그인 검증을 실패했습니다."), - REFRESH_TOKEN_NOT_FOUND(HttpStatus.NOT_FOUND.value(), "refresh token이 존재하지 않습니다."); + EXPIRED_JWT_TOKEN(HttpStatus.UNAUTHORIZED.value(), "만료된 refresh 토큰입니다."); private final int status; private final String message; }