From 0f6249829c35bfc47055013182f4afd16c4256aa Mon Sep 17 00:00:00 2001 From: Jeongmin39 Date: Fri, 3 Jan 2025 17:23:15 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20RefreshTokenService=20=ED=86=A0?= =?UTF-8?q?=ED=81=B0=20=EC=A1=B0=ED=9A=8C=20=EB=A9=94=EC=86=8C=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/auth/jwt/redis/RefreshTokenService.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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)) {