Skip to content

Commit

Permalink
Merge pull request #75 from taking/taking
Browse files Browse the repository at this point in the history
Fix: Email Auth Bug Fixed
  • Loading branch information
taking authored Nov 14, 2023
2 parents 15ba991 + 267e7ff commit a9b889b
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions nw/src/main/java/lab/cherry/nw/service/Impl/AuthServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,28 @@ public void reConfirmEmail(String userid, String email) {

UserEntity userEntity = userRepository.findByuseridAndEmail(userid, email).orElseThrow(() -> new CustomException(ErrorCode.ENTITY_NOT_FOUND));

EmailAuthEntity emailAuthEntity = emailAuthRepository.findById(userEntity.getId())
.orElseThrow(() -> new CustomException(ErrorCode.EMAIL_AUTH_ERROR));
Optional<EmailAuthEntity> emailAuthEntity = emailAuthRepository.findById(userEntity.getId());
if(emailAuthEntity.isEmpty()) {

ObjectId verifiedObjectId = new ObjectId();

EmailAuthEntity emailAuthEntity2 = EmailAuthEntity.builder()
.id(userEntity.getId())
.user(userEntity)
.email(email)
.token(verifiedObjectId.toString())
.expired(LocalDateTime.now().plusMinutes(5L))
.build();

emailAuthRepository.save(emailAuthEntity2);
emailAuthService.ConfirmEmailSend(emailAuthEntity2.getEmail(), emailAuthEntity2.getToken());
} else {

emailAuthEntity = emailAuthService.updateExpired(userEntity.getId());
emailAuthService.ConfirmEmailSend(emailAuthEntity.getEmail(), emailAuthEntity.getToken());
EmailAuthEntity emailAuthEntity2 = emailAuthEntity.get();
emailAuthEntity2 = emailAuthService.updateExpired(userEntity.getId());
emailAuthService.ConfirmEmailSend(emailAuthEntity2.getEmail(), emailAuthEntity2.getToken());

}
}

public void forgotPassword(String userid, String email) {
Expand Down

0 comments on commit a9b889b

Please sign in to comment.