public ActionResult Login(UserLoginViewModel model, string returnUrl) { if (ModelState.IsValid) { string hash = _service.GetHashString(model.Password); User user = _service.FirstOrDefault(u => u.Email == model.Email && u.Password == hash); if(user== null) { ModelState.AddModelError("", "Неверный логин или пароль."); } else { FormsAuthentication.SetAuthCookie(user.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl)) { return Redirect(returnUrl); } else { return RedirectToAction("Index", "Chat"); } } } ViewBag.returnUrl = returnUrl; return View(model); }
public ActionResult Login(string returnUrl) { UserLoginViewModel user = new UserLoginViewModel(); ViewBag.returnUrl = returnUrl; return View(user); }