From f7032eb86d537a77ed81d8d311cd5e0b1181dd82 Mon Sep 17 00:00:00 2001 From: 101 Date: Thu, 25 Jan 2024 01:40:56 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../daemawiki/domain/mail/service/MailVerify.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/example/daemawiki/domain/mail/service/MailVerify.java b/src/main/java/com/example/daemawiki/domain/mail/service/MailVerify.java index 86eebe28..97785f9b 100644 --- a/src/main/java/com/example/daemawiki/domain/mail/service/MailVerify.java +++ b/src/main/java/com/example/daemawiki/domain/mail/service/MailVerify.java @@ -19,15 +19,21 @@ public MailVerify(AuthMailRepository authMailRepository, AuthCodeRepository auth } public Mono execute(AuthCodeVerifyRequest request) { - return getAuthCode(request.mail(), request.authCode()) - .flatMap(authCode -> mailRepository.save(AuthMail.builder() - .mail(request.mail()) - .build()) + String mail = request.mail(); + + return getAuthCode(mail, request.authCode()) + .flatMap(authCode -> save(mail) .then(codeRepository.delete(authCode)) .thenReturn(true)) .switchIfEmpty(Mono.just(false)); } + private Mono save(String mail) { + return mailRepository.save(AuthMail.builder() + .mail(mail) + .build()); + } + private Mono getAuthCode(String mail, String authCode) { return codeRepository.findByMailAndCode(mail, authCode); }