Skip to content

Commit

Permalink
feat: RefreshTokenService 토큰 조회 메소드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeongmin39 committed Jan 3, 2025
1 parent e46cfa4 commit 0f62498
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 0f62498

Please sign in to comment.