Skip to content

feat(User,Token): 리프레시 토큰 중복 저장 로직 수정#71

Merged
HyemIin merged 1 commit intodevelopfrom
feature/#69-리프레시토큰중복저장로직수정
Jul 8, 2025

Hidden character warning

The head ref may contain hidden characters: "feature/#69-\ub9ac\ud504\ub808\uc2dc\ud1a0\ud070\uc911\ubcf5\uc800\uc7a5\ub85c\uc9c1\uc218\uc815"
Merged

feat(User,Token): 리프레시 토큰 중복 저장 로직 수정#71
HyemIin merged 1 commit intodevelopfrom
feature/#69-리프레시토큰중복저장로직수정

Conversation

@HyemIin
Copy link
Copy Markdown
Member

@HyemIin HyemIin commented Jul 8, 2025

작업 요약

Issue Link

문제점 및 어려움

해결 방안

Reference

Summary by CodeRabbit

  • 버그 수정

    • 리프레시 토큰 갱신 시 기존 토큰을 삭제 후 새로 생성하는 방식에서, 기존 토큰 정보를 직접 업데이트하는 방식으로 변경하여 처리 과정이 간소화되었습니다.
  • 정리

    • 사용되지 않는 import 구문이 제거되어 코드가 더 깔끔해졌습니다.

@HyemIin HyemIin self-assigned this Jul 8, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jul 8, 2025

Walkthrough

TokenServiceupdateRefreshToken 메서드가 기존 토큰 엔티티를 삭제 후 새로 생성하는 방식에서, 기존 엔티티의 값을 직접 수정하는 방식으로 변경되었습니다. TokenController에서는 불필요한 import만 제거되었으며, 외부 인터페이스의 시그니처는 변경되지 않았습니다.

Changes

파일 경로 변경 요약
.../applicationadmin/token/service/TokenService.java
.../applicationuser/token/service/TokenService.java
updateRefreshToken 메서드가 기존 토큰 삭제 및 새로 저장에서, 기존 엔티티 내부 값 직접 수정으로 변경됨
.../applicationuser/token/controller/TokenController.java 불필요한 import 문 제거

Possibly related PRs

Suggested reviewers

  • Jjiggu
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions Bot requested a review from Jjiggu July 8, 2025 08:20
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between fe7a7cb and b31fc01.

📒 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));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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" src

Length 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.

@HyemIin HyemIin merged commit 5b7b907 into develop Jul 8, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant