コード例 #1
0
 @Override
 @Transactional
 public void sendPasswordLink(String email) throws UserNotFoundException {
   User user = userManager.findUserByEmail(email);
   if (user == null) {
     throw new UserNotFoundException(email);
   }
   ActivationCode activationCode = createCode(user, ActivationCode.PW);
   activationCodeDao.save(activationCode);
   sendPasswordLinkEmail(user, activationCode.getActivationcode());
 }
コード例 #2
0
  @Override
  @Transactional
  public User register(String email, String userName, String pw, String name) {

    // Do the registration logic...
    User user = userManager.createUser(email, userName, pw, name);
    ActivationCode activationCode = createCode(user, ActivationCode.REGISTER);
    activationCodeDao.save(activationCode);
    sendConfirmationEmail(user, activationCode.getActivationcode());
    return user;
  }
コード例 #3
0
 @Override
 @Transactional
 public void changePassword(String codeAsString, String newPassword)
     throws ActivationCodeException {
   ActivationCode code =
       activationCodeDao.findOneByExample(new ActivationCode(codeAsString, ActivationCode.PW));
   if (code == null) {
     throw new ActivationCodeException(ActivationCodeException.Type.notexist);
   }
   if (code.getUsed() != null && code.getUsed()) {
     throw new ActivationCodeException(ActivationCodeException.Type.used);
   }
   userManager.changePassword(code.getUserId(), newPassword);
   code.setUsed(true);
   activationCodeDao.save(code);
 }
コード例 #4
0
 @Override
 @Transactional
 public void finish(String activationCodeAsString) throws ActivationCodeException {
   ActivationCode code =
       activationCodeDao.findOneByExample(
           new ActivationCode(activationCodeAsString, ActivationCode.REGISTER));
   if (code == null) {
     throw new ActivationCodeException(ActivationCodeException.Type.notexist);
   }
   if (code.getUsed() != null && code.getUsed()) {
     throw new ActivationCodeException(ActivationCodeException.Type.used);
   }
   code.setUsed(true);
   userManager.unlockUser(code.getUserId());
   activationCodeDao.save(code);
 }