Skip to content

Commit

Permalink
[#2] refactor : 에러코드 수정 및 null 체크 로직 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
princenim committed Mar 29, 2024
1 parent d5571df commit 46bb065
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,18 @@ public void signUp(UserDto userDto) {

public void sendVerificationCode(EmailRequestDto emailRequestDto) {
Boolean hasKey = redisTemplate.hasKey(emailRequestDto.getEmail());
if (hasKey == null) {
throw new CustomException(ErrorCode.FAIL_SEND_EMAIL);
}

if (hasKey) {
throw new CustomException(ErrorCode.TOO_FREQUENT_VERIFICATION_REQUEST);
throw new CustomException(ErrorCode.FREQUENT_VERIFICATION_REQUEST);
}

String verificationCode = createRandomNumber();
log.info("{}'s verification code = {}", emailRequestDto.getEmail(), verificationCode);

emailUtil.sendEmail(verificationCode, emailRequestDto.getEmail());

ValueOperations<String, String> valueOperations = redisTemplate.opsForValue();
valueOperations.set(emailRequestDto.getEmail(), verificationCode, 5,
TimeUnit.MINUTES);

emailUtil.sendEmail(verificationCode, emailRequestDto.getEmail());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public enum ErrorCode {
INVALID_INPUT(HttpStatus.BAD_REQUEST, "입력값이 유효하지 않습니다"),
PASSWORD_MISMATCH(HttpStatus.BAD_REQUEST, "두 비밀번호가 일치하지 않습니다."),
EMAIL_ALREADY_EXISTS(HttpStatus.BAD_REQUEST, "이미 존재하는 이메일입니다."),
TOO_FREQUENT_VERIFICATION_REQUEST(HttpStatus.BAD_REQUEST, "잦은 인증번호 요청은 불가능합니다."),
FREQUENT_VERIFICATION_REQUEST(HttpStatus.BAD_REQUEST, "잦은 인증번호 요청은 불가능합니다."),

/* 500 INTERNAL_SERVER_ERROR : 서버 오류 */
FAIL_SEND_EMAIL(HttpStatus.INTERNAL_SERVER_ERROR, "이메일 전송에 실패하였습니다.");
Expand Down

0 comments on commit 46bb065

Please sign in to comment.