예제 #1
0
 public ActionResult LogIn(string returnUrl)
 {
     var model = new LogInModel
     {
         ReturnUrl = returnUrl
     };
     
     return View(model);
 }
예제 #2
0
        public async Task<ActionResult> LogIn(LogInModel model)
        {
            if (!ModelState.IsValid)
            {
                return View();
            }

            var user = await userManager.FindAsync(model.Email, model.Password);

            if (user != null)
            {
                await SignIn(user);
                return Redirect(GetRedirectUrl(model.ReturnUrl));
            }

            // user authN failed
            ModelState.AddModelError("", "Invalid email or password");
            return View();
        }