Conversation
WalkthroughThe changes introduce explicit handling and storage of refresh tokens during user registration. In the sign-up process, after generating a token pair for the new user, the refresh token is now saved using a dedicated service. This is achieved by adding a new method to the token refresh service for storing the refresh token with an expiration. The sign-up logic is updated to use this method before returning the registration response. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant SignUpUsecaseImpl
participant TokenRefreshService
participant JwtTokenFactory
User->>SignUpUsecaseImpl: register(command)
SignUpUsecaseImpl->>JwtTokenFactory: generateTokenPair(user)
JwtTokenFactory-->>SignUpUsecaseImpl: TokenPair
SignUpUsecaseImpl->>TokenRefreshService: saveRefreshToken(userPublicId, refreshToken)
TokenRefreshService-->>SignUpUsecaseImpl: (ack)
SignUpUsecaseImpl-->>User: SignupUserResponse(user, TokenPair)
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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: 0
🧹 Nitpick comments (1)
src/main/java/org/runimo/runimo/auth/service/TokenRefreshService.java (1)
24-26: Add parameter validation and documentation for the new saveRefreshToken methodThe method implementation looks good functionally, but could benefit from parameter validation and documentation to improve robustness and maintainability.
Consider adding parameter validation and JavaDoc:
+ /** + * Saves a refresh token for a user with the configured expiration time. + * + * @param userId the ID of the user + * @param refreshToken the refresh token to save + * @throws IllegalArgumentException if userId or refreshToken is null or empty + */ public void saveRefreshToken(String userId, String refreshToken) { + if (userId == null || userId.isEmpty()) { + throw new IllegalArgumentException("User ID cannot be null or empty"); + } + if (refreshToken == null || refreshToken.isEmpty()) { + throw new IllegalArgumentException("Refresh token cannot be null or empty"); + } refreshTokenCache.put(userId, refreshToken, Duration.ofMillis(refreshTokenExpiry)); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/main/java/org/runimo/runimo/auth/service/SignUpUsecaseImpl.java(3 hunks)src/main/java/org/runimo/runimo/auth/service/TokenRefreshService.java(1 hunks)
🔇 Additional comments (3)
src/main/java/org/runimo/runimo/auth/service/SignUpUsecaseImpl.java (3)
11-11: LGTM - Appropriate import for TokenPairThe imported TokenPair class is now used as a local variable in the register method, which is a good practice.
32-32: LGTM - Proper dependency injection for TokenRefreshServiceThe TokenRefreshService has been correctly added as a final field and will be automatically injected via the constructor because of the @requiredargsconstructor annotation.
49-54: LGTM - Properly saving refresh token after user registrationGood implementation of storing the refresh token immediately after token generation. The code now ensures that refresh tokens are properly persisted during user registration, fixing the issue mentioned in the PR description.
A few observations:
- The code extracts the TokenPair to a local variable, improving readability
- It correctly passes the user's publicId as the key for the refresh token
- The change is consistent with how refresh tokens are handled elsewhere in the codebase
작업내역
리프레쉬토큰을 로그인 이후 저장하지 않음. 저장하는 로직을 추가
Summary by CodeRabbit