diff --git a/be/src/main/java/yeonba/be/login/service/LoginService.java b/be/src/main/java/yeonba/be/login/service/LoginService.java index 9dd00eec..2dec3f10 100644 --- a/be/src/main/java/yeonba/be/login/service/LoginService.java +++ b/be/src/main/java/yeonba/be/login/service/LoginService.java @@ -10,6 +10,7 @@ import yeonba.be.user.entity.User; import yeonba.be.user.repository.UserQuery; import yeonba.be.util.EmailService; +import yeonba.be.util.RedisUtil; import yeonba.be.util.SmsService; import yeonba.be.util.TemporaryPasswordGenerator; import yeonba.be.util.VerificationCodeGenerator; @@ -18,6 +19,8 @@ @RequiredArgsConstructor public class LoginService { + private final long VERIFICATION_CODE_TTL = 5; + private final String TEMPORARY_PASSWORD_EMAIL_SUBJECT = "연바(연애는 바로 지금) 임시비밀번호 발급"; private final String TEMPORARY_PASSWORD_EMAIL_TEXT = "임시비밀번호 : %s"; private final String VERIFICATION_CODE_MESSAGE = "연바(연애는 바로 지금) 인증 코드 : %s"; @@ -27,6 +30,7 @@ public class LoginService { private final EmailService emailService; private final SmsService smsService; + private final RedisUtil redisUtil; /* 임시 비밀번호는 다음 과정을 거친다. 1. 요청 이메일 기반 사용자 조회 @@ -58,7 +62,12 @@ public void sendVerificationCodeMessage(UserPhoneNumberVerifyRequest request) { throw new GeneralException(UserException.USER_NOT_FOUND); } + // 인증 코드 재발급 요청시 기존 발급 내역 삭제 + redisUtil.deleteData(phoneNumber); + String code = VerificationCodeGenerator.generateVerificationCode(); + redisUtil.putData(phoneNumber, code, VERIFICATION_CODE_TTL); + String message = String.format(VERIFICATION_CODE_MESSAGE, code); smsService.sendMessage(phoneNumber, message); }