コード例 #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();
        }