public ActionResult LogIn(string returnUrl) { var model = new LoginModel { ReturnUrl = returnUrl }; return View(model); }
public async Task<ActionResult> LogIn(LoginModel model) { if (!ModelState.IsValid) { return View(); } var user = await _userManager.FindAsync(model.Email, model.Password); if (user != null) { var identity = await _userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie); GetAuthenticationManager().SignIn(identity); return Redirect(GetRedirectUrl(model.ReturnUrl)); } ModelState.AddModelError("", "invalid email or password"); return View(); }