Skip to content

Commit

Permalink
Merge pull request #93 from YAPP-Github/feat/ISSUE-92
Browse files Browse the repository at this point in the history
chore: update email code
  • Loading branch information
Seokyeong237 authored Feb 17, 2024
2 parents c4b6228 + 23e5139 commit abf4702
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/main/java/com/fullcar/core/response/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public enum ErrorCode {
CANNOT_CHANGE_FORM_STATE(BAD_REQUEST, "카풀에 등록된 운전자만 신청서 수락/거절을 할 수 있습니다."),
CANNOT_CLOSE_CARPOOL(BAD_REQUEST, "삭제 권한이 없습니다."),
INVALID_FORM_STATE(BAD_REQUEST, "유효하지 않은 신청서 상태입니다."),
EXISTED_CODE_IN_MAIL(BAD_REQUEST, "이미 인증번호를 보냈습니다."),
NOT_MATCHED_CODE(BAD_REQUEST, "인증번호가 일치하지 않습니다."),

/* 401 UNAUTHORIZED */
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/fullcar/member/domain/mail/Mail.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ public class Mail {
private MemberId memberId;

private Integer code;

public void updateEmailCode(Integer code) {
this.code = code;
}
}
10 changes: 7 additions & 3 deletions src/main/java/com/fullcar/member/infra/MailClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Random;

@Service
//@Component
@RequiredArgsConstructor
public class MailClient implements MailService {
private final BlacklistRepository blacklistRepository;
Expand All @@ -41,10 +42,13 @@ public void sendMail(Member member, EmailRequestDto emailRequestDto) {
String emailDomain = email.substring(email.lastIndexOf("@")+1);
blacklistRepository.findByEmailThrow(emailDomain);

if (mailRepository.findByMemberId(member.getId()) != null) {
throw new CustomException(ErrorCode.EXISTED_CODE_IN_MAIL);
Mail mail = mailRepository.findByMemberId(member.getId());
if (mail != null) {
mail.updateEmailCode(authNum);
}
else {
mailRepository.saveAndFlush(mailMapper.toEntity(member, authNum));
}
mailRepository.saveAndFlush(mailMapper.toEntity(member, authNum));

EmailMessage emailMessage = mailMapper.toMessageEntity(emailRequestDto);
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
Expand Down

0 comments on commit abf4702

Please sign in to comment.