feat(User,Token): 리프레시 토큰 중복 저장 로직 수정#71
Conversation
Walkthrough
Changes
Possibly related PRs
Suggested reviewers
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/token/service/TokenService.java (1)
61-61: 만료 기간 하드코딩을 개선하세요.30일 만료 기간이 하드코딩되어 있습니다. 이를 설정 파일로 외부화하여 유지보수성을 높이는 것을 고려해보세요.
+@Value("${token.refresh.expiration.days:30}") +private int refreshTokenExpirationDays; -token.updateRefreshToken(newRefreshToken, LocalDateTime.now().plusDays(30)); +token.updateRefreshToken(newRefreshToken, LocalDateTime.now().plusDays(refreshTokenExpirationDays));nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/token/service/TokenService.java (1)
61-61: 타임존 고려사항을 확인하세요.
LocalDateTime.now()를 사용하고 있는데, 서버의 시스템 타임존에 의존하게 됩니다. 멀티 리전 환경에서 일관된 시간 처리를 위해 UTC 시간 사용을 고려해보세요.-token.updateRefreshToken(newRefreshToken, LocalDateTime.now().plusDays(30)); +token.updateRefreshToken(newRefreshToken, LocalDateTime.now(ZoneOffset.UTC).plusDays(30));또는 application.properties에서 타임존을 명시적으로 설정하는 것을 고려해보세요.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/token/service/TokenService.java(1 hunks)nowait-app-user-api/src/main/java/com/nowait/applicationuser/token/controller/TokenController.java(0 hunks)nowait-app-user-api/src/main/java/com/nowait/applicationuser/token/service/TokenService.java(1 hunks)
💤 Files with no reviewable changes (1)
- nowait-app-user-api/src/main/java/com/nowait/applicationuser/token/controller/TokenController.java
🔇 Additional comments (2)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/token/service/TokenService.java (1)
61-61: 삭제 후 생성 방식에서 업데이트 방식으로의 변경을 승인합니다.기존 토큰 엔티티를 삭제하고 새로 생성하는 방식에서 기존 엔티티를 직접 업데이트하는 방식으로 변경한 것은 좋은 개선입니다. 이는 데이터베이스 연산을 줄이고 성능을 향상시킵니다.
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/token/service/TokenService.java (1)
61-61: Admin과 User API 간 일관성이 잘 유지되었습니다.Admin API와 User API의 TokenService가 동일한 방식으로 리팩토링되어 일관성이 잘 유지되고 있습니다. 이는 코드 베이스 전체에서 동일한 패턴을 사용하여 유지보수성을 높입니다.
| tokenRepository.delete(token); | ||
| Token newToken = Token.toEntity(token.getUser(), newRefreshToken, LocalDateTime.now().plusDays(30)); | ||
| tokenRepository.save(newToken); | ||
| token.updateRefreshToken(newRefreshToken, LocalDateTime.now().plusDays(30)); |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Token 엔티티의 updateRefreshToken 메서드 존재 여부를 확인하세요.
코드에서 token.updateRefreshToken(newRefreshToken, LocalDateTime.now().plusDays(30))를 호출하고 있는데, Token 엔티티에 해당 메서드가 존재하는지 확인이 필요합니다.
다음 스크립트를 실행하여 Token 엔티티의 updateRefreshToken 메서드를 확인하세요:
🏁 Script executed:
#!/bin/bash
# Token 엔티티에서 updateRefreshToken 메서드를 검색
ast-grep --pattern $'class Token {
$$$
updateRefreshToken($$$) {
$$$
}
$$$
}'Length of output: 90
다른 방식으로 메서드 존재 여부를 확인해보겠습니다. 전체 소스에서 updateRefreshToken 호출/정의 검색:
🏁 Script executed:
#!/bin/bash
# 전체 소스에서 updateRefreshToken 메서드 존재 여부 확인
rg -n "updateRefreshToken" srcLength of output: 74
Token 엔티티 정의 위치에서 메서드를 다시 찾아보겠습니다.
🏁 Script executed:
#!/bin/bash
# 프로젝트 루트에서 updateRefreshToken 정의/호출 위치 검색
rg -n "updateRefreshToken" -g "*.java" .
# Token 엔티티 클래스 파일 위치 확인
rg -n "class Token" -g "*.java" .Length of output: 2792
updateRefreshToken 메서드 정의 확인 및 개선 제안
- Token 엔티티(nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/token/entity/Token.java:55)에
public void updateRefreshToken(String refreshToken, LocalDateTime expiredDate) { … }가 정의되어 있습니다. - 남은 개선 사항:
• 만료 기간(30일)을 하드코딩 대신application.yml등의 설정으로 외부화
•LocalDateTime.now()사용으로 인한 타임존 이슈를 방지하기 위해Clock주입 또는ZonedDateTime/Instant활용 검토
🤖 Prompt for AI Agents
In
nowait-app-user-api/src/main/java/com/nowait/applicationuser/token/service/TokenService.java
at line 61, the call to updateRefreshToken uses a hardcoded 30-day expiration
and LocalDateTime.now(), which can cause timezone issues. Refactor to
externalize the expiration period by reading it from application.yml
configuration and inject a Clock instance to obtain the current time, replacing
LocalDateTime.now() with a timezone-aware time source like ZonedDateTime or
Instant derived from the injected Clock.
작업 요약
Issue Link
문제점 및 어려움
해결 방안
Reference
Summary by CodeRabbit
버그 수정
정리