@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); }
@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); }