Skip to content

Conversation

@yskim6772
Copy link
Contributor

@yskim6772 yskim6772 commented Oct 15, 2025

Related issue 🛠

Work Description 📝

  • getCurrentUser 함수 로직 수정

Screenshot 📸

Uncompleted Tasks 😅

  • N/A

To Reviewers 📢

닉네임 수정 후 출퇴근 및 재실자 조회 요청 시
닉네임 값을 참조하고 있었어서 사용자 존재 오류가 발생했었기에
해결 후 hotfix로 올립니다!

Summary by CodeRabbit

  • 버그 수정
    • 일부 로그인 환경에서 간헐적으로 발생하던 “사용자를 찾을 수 없음” 오류를 해결하여 클럽 관련 메뉴와 개인화 기능 접근의 안정성을 높였습니다.
    • 인증 정보 검증을 강화해 재로그인·세션 갱신 등 다양한 시나리오에서 사용자 정보 조회의 일관성을 개선했습니다.
    • 오류 발생 가능성을 줄여 사용자 프로필/활동 조회가 더 매끄럽게 동작합니다.

@coderabbitai
Copy link

coderabbitai bot commented Oct 15, 2025

Walkthrough

getCurrentUser가 닉네임 기반 조회에서 Authentication의 UserPrincipal 기반 조회로 변경되었습니다. SecurityContext에서 Authentication을 가져와 principal의 userId로 User를 로드하며, 타입/존재 검증 실패 시 USER_NOT_FOUND 예외를 던집니다. 관련 import가 추가되고 이전 nickname 기반 로직은 제거되었습니다.

Changes

Cohort / File(s) Change Summary
인증 기반 사용자 조회 로직
src/main/java/com/WhoIsRoom/WhoIs_Server/domain/club/service/ClubService.java
getCurrentUser가 SecurityContext의 Authentication → UserPrincipal(userId) → UserRepository 조회 흐름으로 수정. nickname 기반 getName()/findByNickName 로직 제거. UserPrincipal/Authentication import 추가. 예외 코드는 기존 정책 유지.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Client as Client
    participant ClubService as ClubService.getCurrentUser()
    participant SecCtx as SecurityContext
    participant Auth as Authentication
    participant Principal as UserPrincipal
    participant UserRepo as UserRepository

    Client->>ClubService: 호출
    ClubService->>SecCtx: getContext()
    SecCtx-->>ClubService: SecurityContext
    ClubService->>Auth: getAuthentication()
    Auth-->>ClubService: Authentication
    alt principal가 UserPrincipal 아님 또는 null
        ClubService-->>Client: throw USER_NOT_FOUND
    else UserPrincipal 유효
        ClubService->>Principal: getPrincipal()
        Principal-->>ClubService: userId
        ClubService->>UserRepo: findById(userId)
        alt User 존재
            UserRepo-->>ClubService: User
            ClubService-->>Client: User 반환
        else 미존재
            ClubService-->>Client: throw USER_NOT_FOUND
        end
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

닉네임은 흘러가도 ID는 남아,
보안 맥락 타고 온 진짜 나를 잡아.
Principal 한 줄, 오류는 사라져—
출퇴근도 안심하고 체크하자요.
오늘의 핫픽스, 가볍게 굿바이! 🚀

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed 제목 “[Hotfix] 닉네임 수정 후 사용자 존재 오류 해결”은 닉네임 변경 후 발생하던 사용자 조회 오류를 해결하는 핵심 변경 사항을 명확하고 간결하게 요약하고 있어 PR의 주된 목적과 일치합니다.
Linked Issues Check ✅ Passed getCurrentUser 메서드를 닉네임 기반 조회에서 UserPrincipal의 userId 조회 방식으로 개선하여 닉네임 변경 후 발생하던 ‘사용자 존재하지 않음’ 오류를 해결함으로써 링크된 이슈 #19의 요구사항을 충족합니다.
Out of Scope Changes Check ✅ Passed PR에서 수정된 부분은 오직 getCurrentUser 로직 개선뿐이며 링크된 이슈의 범위를 벗어나는 다른 코드 변경이 없습니다.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hotfix/#19-user-not-found-error

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b670a6a and 8089969.

📒 Files selected for processing (1)
  • src/main/java/com/WhoIsRoom/WhoIs_Server/domain/club/service/ClubService.java (3 hunks)
🔇 Additional comments (2)
src/main/java/com/WhoIsRoom/WhoIs_Server/domain/club/service/ClubService.java (2)

3-3: 새 import들 추가 확인 완료!

UserPrincipalAuthentication import가 새로운 구현에 맞게 잘 추가되었습니다.

Also applies to: 18-18


67-74: 닉네임 변경 버그 수정 확인! 다만 몇 가지 사항을 검토해주세요.

  • Java 16 이상에서만 지원되는 패턴 매칭 instanceof (… principal) 사용 여부 확인
  • 인증 실패 시 USER_NOT_FOUND 대신 ErrorCode.SECURITY_UNAUTHORIZED (HTTP 401) 사용 검토

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@yskim6772 yskim6772 self-assigned this Oct 15, 2025
@yskim6772 yskim6772 merged commit a2c4fd6 into develop Oct 15, 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.

[Hotfix] 닉네임 수정 후 사용자 존재 오류 해결

2 participants