public ActionResult ChangePassword(ChangePasswordModel model) { if (ModelState.IsValid) { bool changePasswordSucceeded; try { changePasswordSucceeded = identityProvider.ChangePassword(User.Identity.Name, model.OldPassword, model.NewPassword); } catch (Exception) { changePasswordSucceeded = false; } if (changePasswordSucceeded) { return(RedirectToAction("ChangePasswordSuccess")); } else { ModelState.AddModelError("", "The current password is incorrect or the new password is invalid."); } } return(View(model)); }