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); }
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; }