Skip to content

Commit

Permalink
#172 fix: 회원가입을 위한 휴대폰 번호 전송
Browse files Browse the repository at this point in the history
  • Loading branch information
chaerlo127 committed Sep 12, 2023
1 parent 14b5c92 commit 890df22
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class WebSecurityConfig(
c.requestMatchers("/users/eid").permitAll()
c.requestMatchers("/users/reissue").permitAll()
c.requestMatchers("/users/password-reset").permitAll()
c.requestMatchers("/users/phone/*/*").permitAll()
c.requestMatchers("/users/phone/*").permitAll()
c.requestMatchers("/users/email/search").permitAll()
c.requestMatchers("/users/password").permitAll()
Expand Down
14 changes: 13 additions & 1 deletion src/main/kotlin/com/psr/psr/user/controller/UserController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,26 @@ class UserController(
}

/**
* 휴대폰번호 유효
* 휴대폰번호 전송
*/
@PostMapping("/phone/check")
fun checkValidPhone(@RequestBody @Validated validPhoneReq: ValidPhoneReq) : BaseResponse<Any>{
userService.checkValidPhone(validPhoneReq)
return BaseResponse(BaseResponseCode.SUCCESS)
}

/**
* 회원가입을 위한 휴대폰번호 전송
*/
@PostMapping("/phone/check/signup")
fun checkValidPhoneForSignUp(@RequestBody @Validated validPhoneReq: ValidPhoneReq) : BaseResponse<Any>{
// 이미 있는 휴대폰 번호인지 확인
if(userService.checkDuplicatePhone(validPhoneReq.phone)) throw BaseException(BaseResponseCode.EXISTS_PHONE)
// 휴대폰 번호 전송
userService.checkValidPhone(validPhoneReq)
return BaseResponse(BaseResponseCode.SUCCESS)
}

/**
* 휴대폰 인증번호 조회
*/
Expand Down
5 changes: 5 additions & 0 deletions src/main/kotlin/com/psr/psr/user/service/UserService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ class UserService(
return userRepository.existsByNicknameAndStatus(nickname, ACTIVE_STATUS)
}

// 휴대폰번호 중복체크
fun checkDuplicatePhone(phone: String): Boolean{
return userRepository.existsByPhoneAndStatus(phone, ACTIVE_STATUS)
}

// token 생성 extract method
private fun createToken(user: User, password: String): TokenDto {
val authenticationToken = UsernamePasswordAuthenticationToken(user.id.toString(), password)
Expand Down

0 comments on commit 890df22

Please sign in to comment.