public async Task<ActionResult> LoginWithManager(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return View("Login", model); } var signinStatus = await signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, true); if (signinStatus == SignInStatus.Success) { return RedirectToLocal(returnUrl); } if (signinStatus == SignInStatus.LockedOut) { ModelState.AddModelError("", "User is locked out"); } if (signinStatus == SignInStatus.Failure) { ModelState.AddModelError("", "Failed to login: Invalid username or password"); } // If we got this far, something failed, redisplay form return View(model); }
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { var user = await userManager.FindAsync(model.Email, model.Password); if (user != null) { await userManager.SignInAsync(AuthenticationManager, user, model.RememberMe); return RedirectToLocal(returnUrl); } else { ModelState.AddModelError("", "Invalid username or password."); } } // If we got this far, something failed, redisplay form return View(model); }