Skip to content

Commit

Permalink
[QFEED-39] Fix: refreshtoken key 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeHyeonseob committed Nov 28, 2024
1 parent beee6da commit b8fe506
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ public class RedisAuthRepository implements AuthRepository {
@Qualifier("redisTemplateString")
private final RedisTemplate<String, String> redisTemplate;

private String createRedisKey(String token) {
return "auth:refreshToken:" + token;
}


@Override
public Optional<RefreshToken> findByToken(String token) {
String storedToken = redisTemplate.opsForValue().get(token);
String key = createRedisKey(token);
String storedToken = redisTemplate.opsForValue().get(key);
if (storedToken == null) {
return Optional.empty();
}
Expand All @@ -30,11 +35,13 @@ public Optional<RefreshToken> findByToken(String token) {

@Override
public void save(RefreshToken refreshToken) {
redisTemplate.opsForValue().set(refreshToken.getToken(), refreshToken.getToken(), 7, TimeUnit.DAYS);
String key = createRedisKey(refreshToken.getToken());
redisTemplate.opsForValue().set(key, refreshToken.getToken(), 7, TimeUnit.DAYS);
}

@Override
public void deleteByToken(String token) {
redisTemplate.delete(token);
String key = createRedisKey(token);
redisTemplate.delete(key);
}
}

0 comments on commit b8fe506

Please sign in to comment.