use of org.broadleafcommerce.openadmin.server.security.domain.ForgotPasswordSecurityTokenImpl in project BroadleafCommerce by BroadleafCommerce.
the class AdminSecurityServiceImpl method sendResetPasswordNotification.
@Override
@Transactional("blTransactionManager")
public GenericResponse sendResetPasswordNotification(String username) {
GenericResponse response = new GenericResponse();
AdminUser user = null;
if (username != null) {
user = adminUserDao.readAdminUserByUserName(username);
}
checkUser(user, response);
if (!response.getHasErrors()) {
String token = PasswordUtils.generateSecurePassword(TEMP_PASSWORD_LENGTH);
token = token.toLowerCase();
ForgotPasswordSecurityToken fpst = new ForgotPasswordSecurityTokenImpl();
fpst.setAdminUserId(user.getId());
fpst.setToken(encodePassword(token, null));
fpst.setCreateDate(SystemTime.asDate());
forgotPasswordSecurityTokenDao.saveToken(fpst);
HashMap<String, Object> vars = new HashMap<String, Object>();
vars.put("token", token);
String resetPasswordUrl = getResetPasswordURL();
if (!StringUtils.isEmpty(resetPasswordUrl)) {
if (resetPasswordUrl.contains("?")) {
resetPasswordUrl = resetPasswordUrl + "&token=" + token;
} else {
resetPasswordUrl = resetPasswordUrl + "?token=" + token;
}
}
vars.put("resetPasswordUrl", resetPasswordUrl);
emailService.sendTemplateEmail(user.getEmail(), getResetPasswordEmailInfo(), vars);
}
return response;
}
Aggregations