public virtual ActionResult ChangePassword(ChangePasswordViewModel model) { if (ModelState.IsValid) { var result = new ExecutionResults(); var user = new User { UserID = SecurityContextManager.CurrentIdentity.Ticket.UserSession.UserID, Name = model.UserName, PasswordHash = model.ConfirmPassword }; if (UserManager.UpdateUser(user, model.OldPassword, Request.UserHostAddress, result)) { //success if (this.IsJsonRequest()) return Json(new { success = true }); return RedirectToAction(MVC.Account.ChangePasswordSuccess()); } //failed business layer rules if (this.IsJsonRequest()) return Json(new { success = false, message = result.ToHtmlString() }); for (int e = 0; e < result.Messages.Count; e++) { ModelState.AddModelError(e.ToString(CultureInfo.InvariantCulture), result.Messages[e].Message); } return View(model); } if (this.IsJsonRequest()) return Json(new { success = false, errors = ModelState.ToJson() }); return View(model); //modelstate already populated }
// GET: /Account/ChangePassword public virtual ActionResult ChangePassword() { var model = new ChangePasswordViewModel { UserName = SecurityContextManager.CurrentIdentity.Name }; return View(model); }