public async Task<ActionResult> Login(LoginModel model) { if (!ModelState.IsValid) { return View(); } // Try to find a user in the db with the specified email and password var user = await userManager.FindAsync(model.Email, model.Password); if (user != null) { // Create a claims identity for user await SignIn(user); if (model.ReturnUrl != null) return Redirect(model.ReturnUrl); return RedirectToAction("Index", "Notes"); } ModelState.AddModelError("Password", "Invalid email or password"); return View(); }
public ActionResult Login(string returnUrl) { LoginModel model = new LoginModel { ReturnUrl = returnUrl }; return View(model); }