public virtual ActionResult Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid && FormsAuthentication.Authenticate(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, false); return RedirectToLocal(returnUrl); } // If we got this far, something failed, redisplay form ModelState.AddModelError("", "The user name or password provided is incorrect."); return View(Views.Login, model); }
public virtual async Task<ActionResult> Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { var result = await _signInManager.PasswordSignInAsync(model.UserName, model.Password, isPersistent: false, lockoutOnFailure: false); if (result.Succeeded) { return RedirectToLocal(returnUrl); } } // If we got this far, something failed, redisplay form ModelState.AddModelError(string.Empty, "The user name or password provided is incorrect."); return View(model); }