use of org.activityinfo.server.login.model.ResetPasswordPageModel in project activityinfo by bedatadriven.
the class ResetPasswordController method resetPassword.
@POST
@Produces(MediaType.TEXT_HTML)
@Transactional
public Viewable resetPassword(@FormParam("email") String email) {
try {
User user = userDAO.get().findUserByEmail(email);
user.setChangePasswordKey(SecureTokenGenerator.generate());
user.setDateChangePasswordKeyIssued(new Date());
mailer.send(new ResetPasswordMessage(user));
ResetPasswordPageModel model = new ResetPasswordPageModel();
model.setEmailSent(true);
return model.asViewable();
} catch (NoResultException e) {
ResetPasswordPageModel model = new ResetPasswordPageModel();
model.setLoginError(true);
return model.asViewable();
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Failed to send password reset email", e);
ResetPasswordPageModel model = new ResetPasswordPageModel();
model.setEmailError(true);
return model.asViewable();
}
}
Aggregations