protected virtual bool ChangePasswordCore(ControllerContext controllerContext, SubmissionSetting submissionSetting = null) { var memberAuth = controllerContext.HttpContext.Membership(); if (memberAuth.GetMember().Identity.IsAuthenticated == false) { throw new HttpException((int)System.Net.HttpStatusCode.Unauthorized, ""); } var membership = MemberPluginHelper.GetMembership(); var model = new ChangeMemberPasswordModel(); bool valid = ModelBindHelper.BindModel(model, "", controllerContext, submissionSetting); if (valid) { valid = _manager.Validate(membership, memberAuth.GetMember().Identity.Name, model.OldPassword); if (valid) { _manager.ChangePassword(membership, memberAuth.GetMember().Identity.Name, model.NewPassword); valid = true; } else { valid = false; controllerContext.Controller.ViewData.ModelState.AddModelError("OldPassword", "The old password is incorrect.".RawLabel().ToString()); } } return(valid); }
public virtual ActionResult ChangePassword(ChangePasswordModel model, string @return) { JsonResultData data = new JsonResultData(ModelState); if (ModelState.IsValid) { data.RunWithTry((resultData) => { _manager.ChangePassword(Membership, model.UUID, model.NewPassword); resultData.RedirectUrl = @return; }); } return(Json(data)); }