use of org.lastaflute.web.validation.VaErrorHook in project fess by codelibs.
the class ProfileAction method changePassword.
@Execute
public HtmlResponse changePassword(final ProfileForm form) {
final VaErrorHook toIndexPage = () -> {
form.clearSecurityInfo();
return asIndexHtml();
};
validatePasswordForm(form, toIndexPage);
final String username = getUserBean().map(u -> u.getUserId()).get();
try {
userService.changePassword(username, form.newPassword);
saveInfo(messages -> messages.addSuccessChangedPassword(GLOBAL));
} catch (final Exception e) {
logger.error("Failed to change password for " + username, e);
throwValidationError(messages -> messages.addErrorsFailedToChangePassword(GLOBAL), toIndexPage);
}
return redirect(getClass());
}
Aggregations