コード例 #1
0
 @Override
 public void generateToken(VerificationToken verificationToken) {
   verificationToken.setExpiredTime(
       LocalDateTime.now().plusSeconds(VerificationToken.EXPIRED_PERIOD));
   String unhashedToken =
       verificationToken.getEmail() + verificationToken.getType() + LocalDateTime.now();
   String token = VerificationTokenUtil.getHash(unhashedToken, VerificationTokenUtil.SHA_256);
   verificationToken.setToken(token);
 }
コード例 #2
0
 @Override
 @Transactional(timeout = 60)
 public VerificationToken resentToken(VerificationToken verificationToken) {
   generateToken(verificationToken);
   if (verificationToken.getType() == VerificationTokenPK.Type.PASSWORD_RESET
       && verificationToken.isVerified()) {
     verificationToken.setVerified(false);
   }
   VerificationToken updated = verificationTokenDao.update(verificationToken);
   emailService.sentVerificationToken(
       updated.getEmail(), verificationToken.getType(), updated.getToken());
   return verificationToken;
 }
コード例 #3
0
  @Override
  @Transactional(timeout = 60)
  public VerificationToken registrateNewToken(VerificationToken verificationToken) {
    if (verificationToken.getType() == VerificationTokenPK.Type.PASSWORD_RESET
        && !userService.findByEmail(verificationToken.getEmail()).isPresent()) {
      throw new NotFoundException(
          String.format("The user with email %s was not found.", verificationToken.getEmail()));
    }

    generateToken(verificationToken);
    verificationTokenDao.save(verificationToken);
    emailService.sentVerificationToken(
        verificationToken.getEmail(), verificationToken.getType(), verificationToken.getToken());
    return verificationToken;
  }
コード例 #4
0
 @Override
 public void sendEmailRegistrationToken(VerificationToken verificationToken) {
   emailService.sentVerificationToken(
       verificationToken.getEmail(), verificationToken.getType(), verificationToken.getToken());
 }