diff --git a/src/main/java/com/spot/spotserver/api/auth/jwt/redis/RefreshTokenService.java b/src/main/java/com/spot/spotserver/api/auth/jwt/redis/RefreshTokenService.java index f8602bc..8b4e53c 100644 --- a/src/main/java/com/spot/spotserver/api/auth/jwt/redis/RefreshTokenService.java +++ b/src/main/java/com/spot/spotserver/api/auth/jwt/redis/RefreshTokenService.java @@ -12,12 +12,19 @@ public class RefreshTokenService { @Transactional public void saveRefreshToken(final Long userId, final String refreshToken) { - // 기존 리프레시 토큰 삭제 - deleteRefreshToken(userId); - // 새로운 리프레시 토큰 저장 + String strUserId = userId.toString(); + if (tokenRepository.existsById(strUserId)) { + tokenRepository.deleteById(strUserId); + } tokenRepository.save(Token.of(userId, refreshToken)); } + public String getRefreshToken(final Long userId) { + return tokenRepository.findById(userId.toString()) + .map(Token::getRefreshToken) + .orElse(null); + } + public void deleteRefreshToken(final Long userId) { String strUserId = userId.toString(); if (tokenRepository.existsById(strUserId)) {