Skip to content

Commit

Permalink
Merge pull request #160 from TEAM-MODDY/feat/#152
Browse files Browse the repository at this point in the history
#152 [feat] 전화번호 인증 api 유효성 검사 추가
  • Loading branch information
KWY0218 authored Jan 17, 2024
2 parents e178e18 + ebc42c2 commit 670a448
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public SuccessResponse<UserCreateResponse> createModel(
@ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@PostMapping("/phoneNumber")
public SuccessNonDataResponse sendVerificationCodeMessageToUser(@RequestBody PhoneNumberRequestDto phoneNumberRequestDto) throws IOException {
public SuccessNonDataResponse sendVerificationCodeMessageToUser(@Valid @RequestBody PhoneNumberRequestDto phoneNumberRequestDto) throws IOException {
authService.sendVerificationCodeMessageToUser(phoneNumberRequestDto.phoneNumber());
return SuccessNonDataResponse.success(SEND_VERIFICATION_CODE_SUCCESS);
}
Expand All @@ -136,7 +136,7 @@ public SuccessNonDataResponse sendVerificationCodeMessageToUser(@RequestBody Pho
@ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@PostMapping("/phoneNumber/verify")
public SuccessNonDataResponse verifyCode(@RequestBody VerifyCodeRequestDto verifyCodeRequestDto) {
public SuccessNonDataResponse verifyCode(@Valid @RequestBody VerifyCodeRequestDto verifyCodeRequestDto) {
authService.verifyCode(verifyCodeRequestDto.phoneNumber(), verifyCodeRequestDto.verifyCode());
return SuccessNonDataResponse.success(VERIFICATION_CODE_MATCH_SUCCESS);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
package com.moddy.server.controller.auth.dto.request;

public record PhoneNumberRequestDto(String phoneNumber) {
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Pattern;

public record PhoneNumberRequestDto(
@Schema(example = "01020000000")
@Pattern(regexp = "^010[0-9]{8}$", message = "phoneNumber는 01011112222형태입니다.")
String phoneNumber
) {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
package com.moddy.server.controller.auth.dto.request;

public record VerifyCodeRequestDto(String phoneNumber, String verifyCode) {
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Pattern;

public record VerifyCodeRequestDto(
@Schema(example = "01020000000")
@Pattern(regexp = "^010[0-9]{8}$", message = "phoneNumber는 01011112222형태입니다.")
String phoneNumber,
@Schema(example = "123456")
@Pattern(regexp = "[0-9]{6}$", message = "verifyCode는 123456형태입니다.")
String verifyCode
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.io.IOException;

public interface SmsService {
String MESSAGE_FORM = "[%s] moddy에서 보낸 인증번호입니다. 해당 인증번호는 3분간 유효합니다.";
String MESSAGE_FORM = "[%s] moddy에서 보낸 인증번호입니다.";

boolean sendSms(String to, String verificationCode) throws IOException;
}

0 comments on commit 670a448

Please sign in to comment.