public ActionResult Manage(LocalPasswordModel model) { ViewBag.ReturnUrl = Url.Action("Manage"); if (ModelState.IsValid) { // ChangePassword will throw an exception rather than return false in certain failure scenarios. bool changePasswordSucceeded; try { changePasswordSucceeded = Membership.GetUser().ChangePassword(model.OldPassword, model.NewPassword); } catch (Exception) { changePasswordSucceeded = false; } if (changePasswordSucceeded) { return RedirectToAction("Manage", new { Message = ManageMessageId.ChangePasswordSuccess }); } else { ModelState.AddModelError("", "The current password is incorrect or the new password is invalid."); } } // If we got this far, something failed, redisplay form return View(model); }
public ActionResult ChangePassword() { ViewBag.TitleMessage = "Welcome to HealthReunion Patient Portal"; var loginModel = new LocalPasswordModel(); loginModel.UserId = int.Parse(Session["UserId"].ToString()); return View(loginModel); }
public ActionResult ChangePassword(LocalPasswordModel model) { try { if (model.NewPassword.Equals(model.OldPassword)) throw new Exception("Please use some other password, New Password should not be same as old password."); var userRepository = new UserRepository(); var user = userRepository.GetUserById(int.Parse(Session["PatientId"].ToString())); user.Password = model.NewPassword; userRepository.UpdatePassword(user); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return View(model); } return RedirectToLocal(); }
public ActionResult ChangePassword() { var loginModel = new LocalPasswordModel(); loginModel.UserId = int.Parse(Session["UserId"].ToString()); return View(loginModel); }