public ActionResult PwdEdit(vUserPwdEdit model) { User user = db.Users.Find(model.ID); if (ModelState.IsValid) { if (!string.IsNullOrEmpty(model.Password)) { if (!user.Password.Equals(Helpers.Encryt.GetMD5(model.Password))) { return Redirect("/Shared/Info?msg=" + "您输入原始密码错误!"); } else { user.Password = Helpers.Encryt.GetMD5(model.PasswordNew); db.SaveChanges(); return RedirectToAction("Show/" + model.ID); } } else { db.SaveChanges(); return RedirectToAction("Show/" + model.ID); } } else { ModelState.AddModelError("", "修改的信息输入错误!"); } ViewBag.user = new vUserPwdEdit(user); return View(model); }
public ActionResult PwdEdit(vUserPwdEdit model) { User user = db.Users.Find(model.ID); if (ModelState.IsValid) { FormsAuthentication.SetAuthCookie(model.Username, false); if (!string.IsNullOrEmpty(model.Password)) { if (!user.Password.Equals(Helpers.Encryt.GetMD5(model.Password))) { ModelState.AddModelError("", "原始密码输入不正确"); } else { user.Password = Helpers.Encryt.GetMD5(model.PasswordNew); db.SaveChanges(); return RedirectToAction("Show/" + model.ID); } } else { db.SaveChanges(); return RedirectToAction("Show/" + model.ID); } } else { ModelState.AddModelError("", "修改的信息输入错误!"); } ViewBag.user = new vUserPwdEdit(user); return View(model); }