-
Notifications
You must be signed in to change notification settings - Fork 2
MOSU-273 feat: 등록된 전화번호 확인 api 구현 #274
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
Changes from all commits
0a9d3ab
6527121
5de298d
56d4ffe
445393a
348ff8a
e6b5d58
0373d2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,8 +10,8 @@ | |
| import life.mosu.mosuserver.global.annotation.LoginIdPattern; | ||
| import life.mosu.mosuserver.global.annotation.UserId; | ||
| import life.mosu.mosuserver.global.util.ApiResponseWrapper; | ||
| import life.mosu.mosuserver.presentation.user.dto.request.IsLoginIdAvailableResponse; | ||
| import life.mosu.mosuserver.presentation.user.dto.response.CustomerKeyResponse; | ||
| import life.mosu.mosuserver.presentation.user.dto.response.IsLoginIdAvailableResponse; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainImport relocation looks correct. Consider documenting the new phone number check endpoint here. If this interface drives OpenAPI docs for User endpoints, add the docs method for Search whether the new endpoint is documented elsewhere: 🏁 Script executed: #!/bin/bash
rg -n "check-phoneNumber|IsPhoneNumberAvailableResponse|isPhoneNumberAvailable" -A 5Length of output: 4523 Add OpenAPI documentation for the new phone-number availability endpoint The implementation of • File: src/main/java/life/mosu/mosuserver/presentation/user/UserControllerDocs.java import life.mosu.mosuserver.presentation.user.dto.response.IsPhoneNumberAvailableResponse;
// …
/**
* Check whether a given phone number is available for registration.
*
* @param phoneNumber the phone number to validate
* @return HTTP 200 with availability flag wrapped in ApiResponseWrapper
*/
@GetMapping("/check-phoneNumber")
@Operation(summary = "Check phone-number availability")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "Availability retrieved",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = IsPhoneNumberAvailableResponse.class))),
// … any error responses
})
ResponseEntity<ApiResponseWrapper<IsPhoneNumberAvailableResponse>> isPhoneNumberAvailable(
@Parameter(description = "Phone number to check", required = true)
@PhoneNumberPattern @RequestParam String phoneNumber
);This will keep your OpenAPI docs in sync with the new endpoint. 🤖 Prompt for AI Agents |
||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.validation.annotation.Validated; | ||
| import org.springframework.web.bind.annotation.RequestParam; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package life.mosu.mosuserver.presentation.user.dto.response; | ||
|
|
||
| public record IsPhoneNumberAvailableResponse( | ||
| Boolean isPhoneNumberAvailable | ||
| ) { | ||
|
|
||
| public static IsPhoneNumberAvailableResponse from(Boolean isPhoneNumberAvailable) { | ||
| return new IsPhoneNumberAvailableResponse(isPhoneNumberAvailable); | ||
| } | ||
| } |
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.
🛠️ Refactor suggestion
Use primitive boolean for consistency with isLoginIdAvailable and avoid boxing.
isLoginIdAvailablereturnsboolean; mirror that here to keep the API consistent and reduce boxing.📝 Committable suggestion
🤖 Prompt for AI Agents
💡 Verification agent
🧩 Analysis chain
Validate/normalize phone numbers centrally; rely on DB uniqueness at write time.
Even if the controller validates format, consider normalizing to E.164 within the service layer or a dedicated utility to avoid duplicates from formatting. Also ensure a unique constraint on
phoneNumberto handle TOCTOU races at signup.Verify normalization utilities and DB uniqueness:
🏁 Script executed:
Length of output: 1852
Normalize phone numbers to E.164 and enforce uniqueness at the database level
To avoid duplicate accounts caused by different formats and TOCTOU races on signup:
• In
src/main/java/life/mosu/mosuserver/application/user/UserService.java(lines 55–57), normalizephoneNumberbefore checking availability, e.g.• Consolidate all formatting in
PhoneNumberUtil(e.g. rename/extendformatPhoneNumberWithHyphentonormalizeToE164using libphonenumber) so every service and controller uses the same logic.• In your JPA entity (e.g.
src/main/java/life/mosu/mosuserver/application/user/UserJpaEntity.java), add• Create a database migration (Flyway/Liquibase/DDL) to add a unique index or constraint on the
phone_numbercolumn to guard against concurrent sign-ups.🤖 Prompt for AI Agents