Skip to content

Commit

Permalink
[fix] refresh 토큰 내부 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
KWY0218 committed Feb 5, 2024
1 parent 9a8e704 commit 2ce7c36
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/main/java/com/moddy/server/service/auth/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,13 @@ public void logout(final Long userId) {
}

public TokenPair refresh(final TokenRequestDto tokenRequestDto) {
final String userId = jwtService.getUserIdInToken(tokenRequestDto.accessToken());
final User user = userRepository.findById(Long.parseLong(userId)).orElseThrow(() -> new NotFoundException(USER_NOT_FOUND_EXCEPTION));
if (!jwtService.compareRefreshToken(userId, tokenRequestDto.refreshToken()))
if (!jwtService.verifyToken(tokenRequestDto.refreshToken()))
throw new UnAuthorizedException(TOKEN_TIME_EXPIRED_EXCEPTION);

if (!jwtService.verifyToken(tokenRequestDto.refreshToken()))
final String userId = jwtService.getUserIdInToken(tokenRequestDto.refreshToken());
final User user = userRepository.findById(Long.parseLong(userId)).orElseThrow(() -> new NotFoundException(USER_NOT_FOUND_EXCEPTION));

if (!jwtService.compareRefreshToken(userId, tokenRequestDto.refreshToken()))
throw new UnAuthorizedException(TOKEN_TIME_EXPIRED_EXCEPTION);

final TokenPair tokenPair = jwtService.generateTokenPair(userId);
Expand Down

0 comments on commit 2ce7c36

Please sign in to comment.