-
Notifications
You must be signed in to change notification settings - Fork 1
[FIX] #209: 중복 email 검증 오류 해결 #210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Walkthrough
Changes
Sequence Diagram(s)sequenceDiagram
participant C as Client
participant UC as UserController
participant US as UserService
C->>UC: GET /api/v1/auth/check?email={email}
UC->>UC: CheckDuplicatedEmailRequest req = new(email)
UC->>US: isExistsByEmail(req)
US-->>UC: boolean exists
alt 중복 이메일
UC-->>C: 200 ApiResponse<CheckDuplicatedEmailResponse>(exists=true)
else 미중복
UC-->>C: 200 ApiResponse<CheckDuplicatedEmailResponse>(exists=false)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
🪧 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/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
CI status |
There was a problem hiding this 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/main/java/inha/gdgoc/domain/user/controller/UserController.java (2)
17-22: 컴파일 실패: @RequestParam import 누락
@RequestParam을 사용하지만 import가 없습니다. 즉시 빌드 에러 납니다.아래 import를 추가해 주세요.
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.NotBlank; +import org.springframework.validation.annotation.Validated;
24-27: 메서드 파라미터 검증 활성화를 위해 @validated 추가 권장
@RequestParam수준의 제약이 적용되도록 클래스에@Validated를 추가하는 것을 권장합니다. (전역 설정으로 대체 중이라면 생략 가능)@RequestMapping("/api/v1") @RequiredArgsConstructor @RestController +@Validated public class UserController {
🧹 Nitpick comments (2)
src/main/java/inha/gdgoc/domain/user/controller/UserController.java (2)
31-31: 부적절한 TODO 주석 정리비속어가 포함된 주석은 저장소에 남기지 않는 것이 좋습니다. 필요 시 이슈로 전환하거나 중립적으로 표현해 주세요.
- // TODO 진짜 돌았냐? POST로 바꿔라 + // TODO: 필요 시 정책/보안 검토 후 POST 전환 고려
32-40: 엔드포인트 명명/보안 관점 제안
- 경로 통일성: 다른 컨트롤러의
/check/student-id,/check/phone-number와 맞추려면/auth/check/email같은 명시적 경로가 가독성에 유리합니다.- 계정 열거 방지: 이메일 중복 조회는 열거 공격 표면입니다. 레이트 리밋(예: IP/Key 기반), 캡차, 감사 로그(시도/응답), 응답 표준화(필요 시) 등을 검토해 주세요.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/main/java/inha/gdgoc/domain/user/controller/UserController.java(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/main/java/inha/gdgoc/domain/user/controller/UserController.java (2)
src/main/java/inha/gdgoc/domain/user/service/UserService.java (1)
isExistsByEmail(31-33)src/main/java/inha/gdgoc/domain/recruit/controller/RecruitMemberController.java (2)
GetMapping(62-72)GetMapping(74-85)
🔇 Additional comments (1)
src/main/java/inha/gdgoc/domain/user/controller/UserController.java (1)
36-37: 서비스 호출로 DTO 재구성하는 방식은 적절합니다쿼리 파라미터로 받은 값을 DTO로 감싸 서비스에 위임하는 흐름은 일관되고 테스트 용이합니다.
| @RequestParam String email | ||
| ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
쿼리 파라미터로 바뀌면서 입력 검증이 빠졌습니다 — 필수/형식 검증 추가 권장
기존 @RequestBody @Valid 경로에서 넘어오던 Bean Validation이 사라졌을 가능성이 큽니다. 최소한 공백/형식 검증을 파라미터에 직접 부여해 동일한 계약을 유지하세요.
아래처럼 수정 제안드립니다.
- @RequestParam String email
+ @RequestParam
+ @NotBlank(message = "이메일은 필수 입력 값입니다.")
+ @Email(message = "유효하지 않은 이메일 형식입니다.")
+ String email다음 스크립트로 프로젝트가 jakarta.validation 또는 javax.validation 중 무엇을 사용 중인지, 그리고 컨트롤러 메서드 파라미터 검증이 활성화되어 있는지 확인해 주세요.
🏁 Script executed:
#!/bin/bash
# jakarta/javax 사용 현황
rg -nP 'import\s+(jakarta|javax)\.validation' -C1
# @Validated 사용 여부(메서드/파라미터 검증용)
rg -nP '@Validated' -g 'src/**/controller/**.java' -C2
# 이 엔드포인트 사용처(클라이언트/문서 영향도 확인)
rg -nP '/api/v1/auth/check\b' -C2Length of output: 1441
UserController 클래스에 @validated 추가 및 이메일 파라미터 검증 어노테이션 적용
파라미터 검증이 활성화되어 있지 않으므로, jakarta.validation 제약(@notblank, @Email)을 사용하려면 클래스에 @Validated를 추가하고 이메일 파라미터에 다음과 같이 어노테이션을 부여하세요:
diff --git a/src/main/java/inha/gdgoc/domain/user/controller/UserController.java b/src/main/java/inha/gdgoc/domain/user/controller/UserController.java
index e69de29..abcd123 100644
--- a/src/main/java/inha/gdgoc/domain/user/controller/UserController.java
+++ b/src/main/java/inha/gdgoc/domain/user/controller/UserController.java
@@ -1,7 +1,11 @@
package inha.gdgoc.domain.user.controller;
+import org.springframework.validation.annotation.Validated;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.Email;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/v1/auth")
+@Validated
public class UserController {
@GetMapping("/check")
- public ResponseEntity<?> checkEmail(@RequestParam String email) {
+ public ResponseEntity<?> checkEmail(
+ @RequestParam
+ @NotBlank(message = "이메일은 필수 입력 값입니다.")
+ @Email(message = "유효하지 않은 이메일 형식입니다.")
+ String email
+ ) {
// …
}
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @RequestParam String email | |
| ) { | |
| package inha.gdgoc.domain.user.controller; | |
| import org.springframework.validation.annotation.Validated; | |
| import jakarta.validation.constraints.NotBlank; | |
| import jakarta.validation.constraints.Email; | |
| import org.springframework.http.ResponseEntity; | |
| import org.springframework.web.bind.annotation.GetMapping; | |
| import org.springframework.web.bind.annotation.RequestMapping; | |
| import org.springframework.web.bind.annotation.RequestParam; | |
| import org.springframework.web.bind.annotation.RestController; | |
| @RestController | |
| @RequestMapping("/api/v1/auth") | |
| @Validated | |
| public class UserController { | |
| @GetMapping("/check") | |
| public ResponseEntity<?> checkEmail( | |
| @RequestParam | |
| @NotBlank(message = "이메일은 필수 입력 값입니다.") | |
| @Email(message = "유효하지 않은 이메일 형식입니다.") | |
| String email | |
| ) { | |
| // … | |
| } | |
| } |
🤖 Prompt for AI Agents
In src/main/java/inha/gdgoc/domain/user/controller/UserController.java around
lines 34-35, method parameter validation is not enabled: add the Spring/JSR
validation support by annotating the controller class with @Validated and
annotate the email parameter with @NotBlank and @Email (importing
jakarta.validation.constraints.NotBlank and
jakarta.validation.constraints.Email). Ensure the controller class imports
org.springframework.validation.annotation.Validated and the parameter uses the
validation annotations so the framework enforces the constraints at runtime.
📌 연관된 이슈
#209
✨ 작업 내용
💬 리뷰 요구사항(선택)
Summary by CodeRabbit