From 7031a6c1c2602594378292c863b2a15569825b1b Mon Sep 17 00:00:00 2001 From: 101 Date: Thu, 25 Jan 2024 15:12:44 +0900 Subject: [PATCH] =?UTF-8?q?reissue=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../daemawiki/domain/mail/service/MailSend.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/example/daemawiki/domain/mail/service/MailSend.java b/src/main/java/com/example/daemawiki/domain/mail/service/MailSend.java index e4b6d598..1b3e42fe 100644 --- a/src/main/java/com/example/daemawiki/domain/mail/service/MailSend.java +++ b/src/main/java/com/example/daemawiki/domain/mail/service/MailSend.java @@ -15,6 +15,7 @@ import reactor.core.scheduler.Schedulers; import java.io.UnsupportedEncodingException; +import java.util.Objects; import java.util.Random; @Service @@ -42,6 +43,17 @@ public Mono execute(AuthCodeRequest request) { .then(); } + public Mono reissue(AuthCodeRequest request) { + return getAuthCode(request.mail()) + .flatMap(authCode -> codeRepository.delete(authCode) + .then(execute(request))) + .switchIfEmpty(execute(request)); + } + + private Mono getAuthCode(String mail) { + return codeRepository.findByMail(mail); + } + private Mono sendMail(String to, String authCode) { return Mono.fromCallable(() -> { try {