Search in sources :

Example 1 with VaErrorHook

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());
}
Also used : FessSearchAction(org.codelibs.fess.app.web.base.FessSearchAction) Logger(org.slf4j.Logger) UserPasswordCredential(org.lastaflute.web.login.credential.UserPasswordCredential) Resource(javax.annotation.Resource) Execute(org.lastaflute.web.Execute) LoggerFactory(org.slf4j.LoggerFactory) VaErrorHook(org.lastaflute.web.validation.VaErrorHook) UserService(org.codelibs.fess.app.service.UserService) HtmlResponse(org.lastaflute.web.response.HtmlResponse) LoginAction(org.codelibs.fess.app.web.login.LoginAction) VaErrorHook(org.lastaflute.web.validation.VaErrorHook) Execute(org.lastaflute.web.Execute)

Aggregations

Resource (javax.annotation.Resource)1 UserService (org.codelibs.fess.app.service.UserService)1 FessSearchAction (org.codelibs.fess.app.web.base.FessSearchAction)1 LoginAction (org.codelibs.fess.app.web.login.LoginAction)1 Execute (org.lastaflute.web.Execute)1 UserPasswordCredential (org.lastaflute.web.login.credential.UserPasswordCredential)1 HtmlResponse (org.lastaflute.web.response.HtmlResponse)1 VaErrorHook (org.lastaflute.web.validation.VaErrorHook)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1