[Fix] TmpCheck 쿠키 추가#190
Conversation
Walkthrough로그인 시 사용자의 역할이 TMP_USER인 경우 임시 체크 쿠키를 추가하는 로직이 AuthService에 도입되었습니다. UserService와 UserController의 updateUserInfo 메서드는 HttpServletResponse 파라미터를 추가하여, 사용자 정보 업데이트 시 TmpCheck 쿠키를 삭제하도록 변경되었습니다. JwtProvider에는 TmpCheck 쿠키를 추가/삭제하는 메서드가 새로 도입되었고, 관련 테스트 코드도 이에 맞게 수정되었습니다. Changes
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: 응답
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate unit tests
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. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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
📒 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
#️⃣연관된 이슈
📝작업 내용
📷스크린샷 (선택)
💬리뷰 요구사항(선택)
Summary by CodeRabbit
신규 기능
버그 수정
테스트