use of org.activityinfo.server.login.model.ChangePasswordPageModel in project activityinfo by bedatadriven.
the class ChangePasswordController method changePassword.
@POST
public Response changePassword(@Context UriInfo uri, @FormParam("key") String key, @FormParam("password") String password, @FormParam("password2") String password2) throws IOException, ServletException {
User user = null;
try {
user = userDAO.get().findUserByChangePasswordKey(key);
} catch (NoResultException e) {
return ok(new InvalidInvitePageModel());
}
if (password == null || password.length() < MINIMUM_PASSWORD_LENGTH) {
return ok(new ChangePasswordPageModel(user).setPasswordLengthInvalid(true));
}
if (!password.equals(password2)) {
return ok(new ChangePasswordPageModel(user).setPasswordsNotMatched(true));
}
changePassword(user, password);
return Response.seeOther(uri.getAbsolutePathBuilder().replacePath("/").build()).cookie(authTokenProvider.createNewAuthCookies(user)).build();
}
Aggregations