Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update email code #93

Merged
merged 1 commit into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading