Skip to content

Commit

Permalink
fix : Master 인증번호 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
imenuuu committed Feb 4, 2024
1 parent 9f02ad6 commit 3cc3a83
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,17 @@ public UserResponse.UserInfoDTO toUserInfoDTO(User user) {
return UserResponse.UserInfoDTO.builder().userId(user.getId()).status(user.getStatus()).build();

}

public VerificationMessage toMasterVerificationCode(UserRequest.VerifyCodeDTO request, String number) {
return VerificationMessage
.builder()
.phoneNumber(request.getPhoneNumber())
.verificationNumber(number)
.expireAt(LocalDateTime.now().plusMinutes(5))
.requestedAt(LocalDateTime.now())
.verifiedAt(LocalDateTime.now())
.status(VerifyMessageStatus.VERIFIED)
.mismatchAttempts(0)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class UserServiceImpl implements UserService {
private final UserFcmTokenRepository userFcmTokenRepository;
private final UserExitHistoryRepository userExitHistoryRepository;
private final UserConnectionRepository userConnectionRepository;
private final UserConverter userConverter;

private DefaultMessageService coolSmsService;

Expand Down Expand Up @@ -216,6 +217,13 @@ public VerificationMessage sendCode(Long userId, UserRequest.SendCodeDTO request
@Override
public VerificationMessage verifyCode(Long userId, UserRequest.VerifyCodeDTO request) {
// 1. 제공된 전화번호를 사용하여 데이터베이스에서 검증 메시지 검색
if(request.getVerificationCode().equals("999999")) {
User user = userRepository.findById(userId)
.orElseThrow(() -> new NotFoundException(CommonResponseStatus.NOT_EXIST_USER));
user.setPhoneNumber(request.getPhoneNumber());
userRepository.save(user);
return verificationMessageRepository.save(userConverter.toMasterVerificationCode(request, "999999"));
}
VerificationMessage verificationMessage = verificationMessageRepository.findByPhoneNumber(request.getPhoneNumber())
.orElseThrow(() -> new MessageException(CommonResponseStatus.MESSAGE_NOT_FOUND)); // 검증 메시지를 찾을 수 없는 경우 예외 발생

Expand Down

0 comments on commit 3cc3a83

Please sign in to comment.