Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
ori0o0p committed Jan 24, 2024
1 parent 8f0e42e commit f7032eb
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,21 @@ public MailVerify(AuthMailRepository authMailRepository, AuthCodeRepository auth
}

public Mono<Boolean> 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<AuthMail> save(String mail) {
return mailRepository.save(AuthMail.builder()
.mail(mail)
.build());
}

private Mono<AuthCode> getAuthCode(String mail, String authCode) {
return codeRepository.findByMailAndCode(mail, authCode);
}
Expand Down

0 comments on commit f7032eb

Please sign in to comment.