Search in sources :

Example 1 with ChangePasswordRequest

use of org.mifos.dto.domain.ChangePasswordRequest in project head by mifos.

the class ChangePasswordController method processFormSubmit.

@RequestMapping(method = RequestMethod.POST)
public String processFormSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String cancel, @ModelAttribute("formBean") @Valid ChangePasswordFormBean formBean, BindingResult result, SessionStatus status, HttpServletRequest request) {
    String viewName = HOME_PAGE;
    if (CANCEL_PARAM_VALUE.equals(cancel)) {
        viewName = REDIRECT_AND_LOGOUT;
        status.setComplete();
    } else if (result.hasErrors()) {
        viewName = "changePassword";
    } else {
        try {
            ChangePasswordRequest changePasswordRequest = new ChangePasswordRequest(formBean.getUsername(), formBean.getOldPassword(), formBean.getNewPassword());
            loginServiceFacade.changePassword(changePasswordRequest);
            status.setComplete();
        } catch (BusinessRuleException e) {
            ObjectError error = new ObjectError("passwordUsed", messageSource.getMessage("error.passwordAlreadyUsedException", null, RequestContextUtils.getLocale(request)));
            result.addError(error);
            viewName = "changePassword";
        }
    }
    return viewName;
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ObjectError(org.springframework.validation.ObjectError) ChangePasswordRequest(org.mifos.dto.domain.ChangePasswordRequest) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ChangePasswordRequest (org.mifos.dto.domain.ChangePasswordRequest)1 BusinessRuleException (org.mifos.service.BusinessRuleException)1 ObjectError (org.springframework.validation.ObjectError)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1