use of org.activityinfo.server.login.model.InvalidInvitePageModel 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();
}
use of org.activityinfo.server.login.model.InvalidInvitePageModel in project activityinfo by bedatadriven.
the class ConfirmInviteController method confirm.
@POST
public Response confirm(@Context UriInfo uri, @FormParam("key") String key, @FormParam("locale") String locale, @FormParam("password") String password, @FormParam("name") String name, @FormParam("newsletter") boolean newsletter) throws Exception {
User user = null;
try {
user = userDAO.get().findUserByChangePasswordKey(key);
user.setName(checkNonEmpty(name));
user.setLocale(checkNonEmpty(locale));
user.changePassword(checkNonEmpty(password));
user.clearChangePasswordKey();
user.setEmailNotification(true);
mailingList.subscribe(user, true, newsletter);
return Response.seeOther(uri.getAbsolutePathBuilder().replacePath("/app").build()).cookie(authTokenProvider.createNewAuthCookies(user)).build();
} catch (EntityNotFoundException e) {
return Response.ok(new InvalidInvitePageModel().asViewable()).type(MediaType.TEXT_HTML).build();
} catch (IllegalArgumentException e) {
return Response.ok(ConfirmInvitePageModel.incompleteForm(user).asViewable()).type(MediaType.TEXT_HTML).build();
}
}
Aggregations