Skip to content

Conversation

@hayong39
Copy link
Collaborator

@hayong39 hayong39 commented Aug 7, 2025

#️⃣연관된 이슈

#189

📝작업 내용

로그인 시 role이 TMP_USER인 경우 TmpCheck 쿠키를 추가합니다. 이후, 사용자 정보 입력 시 TmpCheck 쿠키를 제거합니다.

📷스크린샷 (선택)

💬리뷰 요구사항(선택)

Summary by CodeRabbit

  • 신규 기능

    • 임시 사용자 로그인 시 임시 체크 쿠키가 추가로 발급됩니다.
    • 사용자 정보 수정 시 임시 체크 쿠키가 삭제됩니다.
  • 버그 수정

    • 없음
  • 테스트

    • 사용자 정보 수정 관련 테스트에 임시 체크 쿠키 처리 로직이 반영되었습니다.

@hayong39 hayong39 self-assigned this Aug 7, 2025
@hayong39 hayong39 added fix 버그 수정 test 테스트 코드 추가, 수정 BE labels Aug 7, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 7, 2025

Walkthrough

로그인 시 사용자의 역할이 TMP_USER인 경우 임시 체크 쿠키를 추가하는 로직이 AuthService에 도입되었습니다. UserService와 UserController의 updateUserInfo 메서드는 HttpServletResponse 파라미터를 추가하여, 사용자 정보 업데이트 시 TmpCheck 쿠키를 삭제하도록 변경되었습니다. JwtProvider에는 TmpCheck 쿠키를 추가/삭제하는 메서드가 새로 도입되었고, 관련 테스트 코드도 이에 맞게 수정되었습니다.

Changes

Cohort / File(s) Change Summary
AuthService 역할 기반 쿠키 처리
src/main/java/com/ureca/uble/domain/auth/service/AuthService.java
로그인 시 사용자의 역할이 TMP_USER일 경우 TmpCheck 쿠키를 응답에 추가하는 조건문 및 관련 import 추가.
UserController & UserService 시그니처 및 쿠키 삭제
src/main/java/com/ureca/uble/domain/users/controller/UserController.java,
src/main/java/com/ureca/uble/domain/users/service/UserService.java
updateUserInfo 메서드에 HttpServletResponse 파라미터 추가 및 전달, 사용자 정보 업데이트 후 TmpCheck 쿠키 삭제 로직 추가.
JwtProvider TmpCheck 쿠키 메서드 추가
src/main/java/com/ureca/uble/global/security/jwt/JwtProvider.java
TmpCheck 쿠키를 추가/삭제하는 public 메서드 2개(addTmpCheckCookie, deleteTmpCheckCookie) 신설.
UserServiceTest 테스트 코드 수정
src/test/java/com/ureca/uble/domain/users/service/UserServiceTest.java
updateUserInfo 호출부에 MockHttpServletResponse 파라미터 추가, JwtProvider 모킹 추가 등 테스트 코드 시그니처 및 준비 코드 수정.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant UserController
    participant UserService
    participant JwtProvider
    participant AuthService

    Client->>AuthService: login 요청
    AuthService->>JwtProvider: 토큰 생성 및 쿠키 추가
    AuthService->>AuthService: 사용자 역할 확인
    alt 역할이 TMP_USER인 경우
        AuthService->>JwtProvider: addTmpCheckCookie(response)
    end
    AuthService-->>Client: 로그인 응답

    Client->>UserController: updateUserInfo 요청
    UserController->>UserService: updateUserInfo(response, userId, request)
    UserService->>JwtProvider: deleteTmpCheckCookie(response)
    UserService-->>UserController: UpdateUserInfoRes
    UserController-->>Client: 응답
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • TmpCheck 쿠키 추가 #189: 로그인 및 사용자 정보 업데이트 흐름에서 TmpCheck 쿠키의 추가/삭제 로직을 구현하여 본 이슈의 목적을 직접적으로 해결합니다.

Possibly related PRs

Suggested reviewers

  • Eric-HAN-01
  • Yyang-YE

Poem

🐰
쿠키 하나, 둘, 셋
역할 따라 임시 체크도 척!
정보 바꾸면 쿠키는 쓱
로그인 흐름에 새 숨결
토끼는 기뻐, 코드는 깔끔
오늘도 안정, 우리 서버!
🍪✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 d72f06a and c8579f7.

📒 Files selected for processing (1)
  • src/test/java/com/ureca/uble/domain/users/service/UserServiceTest.java (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/java/com/ureca/uble/domain/users/service/UserServiceTest.java
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/UBLE-190-tmpcheck_cookie

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

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate unit tests to generate unit tests for 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.

Copy link

@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: 2

🧹 Nitpick comments (2)
src/main/java/com/ureca/uble/global/security/jwt/JwtProvider.java (2)

91-102: 코드 중복 개선 권장사항

addTmpCheckCookie 메서드가 기존 addAuthCheckCookie와 거의 동일한 구조입니다. 쿠키 이름만 다를 뿐 나머지 로직이 중복됩니다.

다음과 같이 공통 메서드를 추출하여 중복을 제거할 수 있습니다:

+	private void addBooleanCookie(HttpServletResponse response, String cookieName, String value) {
+		ResponseCookie cookie = ResponseCookie.from(cookieName, value)
+			.path("/")
+			.httpOnly(false)
+			.secure(isSecure)
+			.maxAge(REFRESH_TOKEN_VALIDITY_MILLIS / 1000)
+			.sameSite(sameSite)
+			.domain(cookieDomain.isBlank() ? null : cookieDomain)
+			.build();
+		response.addHeader("Set-Cookie", cookie.toString());
+	}
+
 	public void addTmpCheckCookie(HttpServletResponse response) {
-		ResponseCookie cookie = ResponseCookie.from("TmpCheck", "true")
-			.path("/")
-			.httpOnly(false)
-			.secure(isSecure)
-			.maxAge(REFRESH_TOKEN_VALIDITY_MILLIS / 1000)
-			.sameSite(sameSite)
-			.domain(cookieDomain.isBlank() ? null : cookieDomain)
-			.build();
-		response.addHeader("Set-Cookie", cookie.toString());
+		addBooleanCookie(response, "TmpCheck", "true");
 	}

130-142: 코드 중복 개선 권장사항

deleteTmpCheckCookie 메서드도 기존 deleteAuthCheckCookie와 동일한 패턴입니다.

공통 삭제 메서드도 추출할 수 있습니다:

+	private void deleteBooleanCookie(HttpServletResponse response, String cookieName) {
+		ResponseCookie cookie = ResponseCookie.from(cookieName, "")
+			.path("/")
+			.httpOnly(false)
+			.secure(isSecure)
+			.maxAge(0)
+			.sameSite(sameSite)
+			.domain(cookieDomain.isBlank() ? null : cookieDomain)
+			.build();
+		response.addHeader("Set-Cookie", cookie.toString());
+	}
+
 	public void deleteTmpCheckCookie(HttpServletResponse response){
-		ResponseCookie cookie = ResponseCookie.from("TmpCheck", "")
-			.path("/")
-			.httpOnly(false)
-			.secure(isSecure)
-			.maxAge(0)
-			.sameSite(sameSite)
-			.domain(cookieDomain.isBlank() ? null : cookieDomain)
-			.build();
-		response.addHeader("Set-Cookie", cookie.toString());
+		deleteBooleanCookie(response, "TmpCheck");
 	}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a56ef0 and d72f06a.

📒 Files selected for processing (5)
  • src/main/java/com/ureca/uble/domain/auth/service/AuthService.java (2 hunks)
  • src/main/java/com/ureca/uble/domain/users/controller/UserController.java (2 hunks)
  • src/main/java/com/ureca/uble/domain/users/service/UserService.java (4 hunks)
  • src/main/java/com/ureca/uble/global/security/jwt/JwtProvider.java (2 hunks)
  • src/test/java/com/ureca/uble/domain/users/service/UserServiceTest.java (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (3)
src/main/java/com/ureca/uble/domain/auth/service/AuthService.java (1)

75-77: TMP_USER 역할 기반 쿠키 추가 로직 적절함

TMP_USER 역할의 사용자에게만 TmpCheck 쿠키를 추가하는 조건부 로직이 올바르게 구현되었습니다. 쿠키 추가 위치도 적절합니다.

src/main/java/com/ureca/uble/domain/users/service/UserService.java (1)

69-69: 사용자 정보 업데이트 시 TmpCheck 쿠키 삭제 로직 적절함

메서드 시그니처 변경과 쿠키 삭제 로직이 올바르게 구현되었습니다. 사용자 정보 업데이트 완료 후 TmpCheck 쿠키를 삭제하는 것이 논리적으로 적절합니다.

Also applies to: 87-87

src/main/java/com/ureca/uble/domain/users/controller/UserController.java (1)

34-34: 컨트롤러 메서드 시그니처 변경 적절함

HttpServletResponse 파라미터 추가와 서비스 메서드 호출 시 파라미터 전달이 올바르게 구현되었습니다.

Also applies to: 39-39

Copy link
Collaborator

@Yyang-YE Yyang-YE left a comment

Choose a reason for hiding this comment

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

수고하셨어요!

@hayong39 hayong39 merged commit c828d17 into develop Aug 7, 2025
2 checks passed
@Yyang-YE Yyang-YE deleted the fix/UBLE-190-tmpcheck_cookie branch August 7, 2025 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BE fix 버그 수정 test 테스트 코드 추가, 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants