public ActionResult Login(HomeLoginRequest model) { model.Trim(); if (_manageService.Login(model.UserName, model.Password.ToMd5())) { Response.Cookies.Add(new HttpCookie(UserAuthorizationAttribute.CookieUserName, model.UserName)); return RedirectToAction("Index"); } ModelState.AddModelError("_error", "登录密码错误或用户不存在或用户被禁用。"); return View(); }
public ActionResult Login(HomeLoginRequest model) { model.Trim(); var loginUserSession = _manageService.GetUserSession(model.UserName, model.Password.ToMd5(), Request.UserHostAddress); if (loginUserSession != null) { Session[Session.SessionID] = loginUserSession; var userCookie = new HttpCookie(UserAuthorizationAttribute.CookieUserName, model.UserName); Response.Cookies.Add(userCookie); return RedirectToAction("Index"); } ModelState.AddModelError("_error", "登录密码错误或用户不存在或用户被禁用。"); return View(); }