public ActionResult ChangePassword(string currentPassword, string newPassword, string confirmPassword) { ViewData["PasswordLength"] = MinPasswordLength; if (!ValidateChangePassword(currentPassword, newPassword, confirmPassword)) { return(View()); } try { var validated = _membershipService.ValidateUser(User.Identity.Name, currentPassword); if (validated != null) { _membershipService.SetPassword(validated, newPassword); _userEventHandler.ChangedPassword(validated); return(RedirectToAction("ChangePasswordSuccess")); } ModelState.AddModelError("_FORM", T("The current password is incorrect or the new password is invalid.")); return(ChangePassword()); } catch { ModelState.AddModelError("_FORM", T("The current password is incorrect or the new password is invalid.")); return(ChangePassword()); } }
private bool PasswordChangeIsSuccess(string currentPassword, string newPassword, string username) { try { var validated = _membershipService.ValidateUser(username, currentPassword, out List <LocalizedString> validationErrors); if (validated != null) { _membershipService.SetPassword(validated, newPassword); _userEventHandler.ChangedPassword(validated); // if security settings tell to invalidate on password change fire the LoggedOut event if (_orchardServices.WorkContext.CurrentSite.As <SecuritySettingsPart>().ShouldInvalidateAuthOnPasswordChanged) { _userEventHandler.LoggedOut(validated); } return(true); } } catch { ModelState.AddModelError("_FORM", T("The current password is incorrect or the new password is invalid.")); return(false); } return(false); }
private bool PasswordChangeIsSuccess(string currentPassword, string newPassword, string username) { try { var validated = _membershipService.ValidateUser(username, currentPassword); if (validated != null) { _membershipService.SetPassword(validated, newPassword); _userEventHandler.ChangedPassword(validated); return(true); } ModelState.AddModelError("_FORM", T("The current password is incorrect or the new password is invalid.")); return(false); } catch { ModelState.AddModelError("_FORM", T("The current password is incorrect or the new password is invalid.")); return(false); } }