public JsonResult IsOldPasswordMatching(string OldPassword) { //check if Old Password Matches the Users existing password int id = (int)GenFx.val(GenFx.GetCurrentUserDetails("ID")); bool match = db.Users.Any(x => x.Password == OldPassword && x.ID == id); return(Json(match, JsonRequestBehavior.AllowGet)); }
public ActionResult ChangePassword() { int id = (int)GenFx.val(GenFx.GetCurrentUserDetails("ID")); User user = db.Users.Find(id); if (user == null) { return(HttpNotFound()); } return(View()); }
public ActionResult ChangePassword([Bind(Include = "OldPassword,NewPassword,RepeatPassword")] ChangePasswordViewModel cpModel) { int id = (int)GenFx.val(GenFx.GetCurrentUserDetails("ID")); User user = db.Users.Find(id); if (user == null) { return(HttpNotFound()); } if (ModelState.IsValid) { user.Password = cpModel.NewPassword; user.ModifiedDate = DateTime.Now; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); Session["siteMsgTyp"] = "success"; Session["siteMsg"] = "Your password was changed successfully."; return(RedirectToAction("Index", "Home")); } return(View(cpModel)); }