Change comments

This commit is contained in:
hou27
2022-06-18 21:40:29 +09:00
parent 24d40aa46e
commit 6fd9e57bfc
2 changed files with 6 additions and 7 deletions

View File

@@ -93,28 +93,28 @@ public class AuthServiceImpl implements AuthService {
public ResponseEntity<TokenDto> regenerateToken(RegenerateTokenDto refreshTokenDto) {
String refresh_token = refreshTokenDto.getRefresh_token();
try {
// 1. Refresh Token 검증
// Refresh Token 검증
if (!jwtTokenProvider.validateRefreshToken(refresh_token)) {
throw new CustomException("Invalid refresh token supplied", HttpStatus.BAD_REQUEST);
}
// 2. Access Token 에서 User email 를 가져옵니다.
// Access Token 에서 User email를 가져다.
Authentication authentication = jwtTokenProvider.getAuthenticationByRefreshToken(refresh_token);
// 3. Redis 에서 User email 을 기반으로 저장된 Refresh Token 값을 가져옵니다.
String refreshToken = (String)redisTemplate.opsForValue().get(authentication.getName());
// Redis에서 저장된 Refresh Token 값을 가져다.
String refreshToken = redisTemplate.opsForValue().get(authentication.getName());
if(!refreshToken.equals(refresh_token)) {
throw new CustomException("Refresh Token doesn't match.", HttpStatus.BAD_REQUEST);
}
// 4. 새로운 토큰 생성
// 토큰 재발행
String new_refresh_token = jwtTokenProvider.generateRefreshToken(authentication);
TokenDto tokenDto = new TokenDto(
jwtTokenProvider.generateAccessToken(authentication),
new_refresh_token
);
// 5. RefreshToken Redis 업데이트
// RefreshToken Redis 업데이트
redisTemplate.opsForValue().set(
authentication.getName(),
new_refresh_token,

View File

@@ -10,7 +10,6 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
public class RedisConfig {
@Value("${redis.host}")
private String redisHost;