public ActionResult UpdatePwd(LoginModel m) { ModelState.Remove("CheckCode"); ModelState.Remove("UserName"); if (!ModelState.IsValid) { return View(); } if (m.Password.ToMd5() != System.Configuration.ConfigurationManager.AppSettings["SuperPwd"]) { ModelState.AddModelError("Password", "旧密码不正确"); return View(); } SetValue(Request.PhysicalApplicationPath, m.NewPassword.ToMd5()); TempData[StaticDefination.TmpErrMsg] = "密码修改成功"; return View(); }
public ActionResult Login(LoginModel model) { JsonData reply; ModelState.Remove("NewPassword"); ModelState.Remove("ConfirmPassword"); if (!ModelState.IsValid) { reply = new JsonData(ModelState); return Json(reply); } //SysUser user = // context.SysUser.FirstOrDefault(x => x.UserName == model.UserName); //if (user == null) { // ModelState.AddModelError("UserName", "不存在此用户名"); //} else if (user.PWD != model.Password) { // ModelState.AddModelError("Password", "密码输入不正确"); //} if (model.UserName != "Admin") { ModelState.AddModelError("UserName", "不存在此用户名"); } if (model.Password.ToMd5() != System.Configuration.ConfigurationManager.AppSettings["SuperPwd"]) { ModelState.AddModelError("Password", "密码输入不正确"); } object imgCode = Session["ImgCode"]; if (imgCode.ToString() != model.CheckCode.ToUpper()) { ModelState.AddModelError("CheckCode", "验证码输入有误"); } if (!ModelState.IsValid) { reply = new JsonData(ModelState); return Json(reply); } SetUserData(model.UserName, ""); reply = new JsonData(Url.Content("Company.aspx")); return Json(reply); }