use of org.activityinfo.server.mail.ResetPasswordMessage 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();
}
}
use of org.activityinfo.server.mail.ResetPasswordMessage in project activityinfo by bedatadriven.
the class SignUpAddressExistsController 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));
return new SignUpAddressExistsPageModel(email).asEmailSent();
} catch (NoResultException e) {
return new SignUpAddressExistsPageModel().asLoginError();
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Failed to send password reset email", e);
return new SignUpAddressExistsPageModel().asEmailError();
}
}
Aggregations