コード例 #1
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                ApplicationUser user = await _myService.FindUser(model.LoginBag.UserName, model.LoginBag.Password);

                if (user != null)
                {
                    await SignInAsync(user, model.LoginBag.RememberMe);

                    return(RedirectToLocal(returnUrl));
                }
                else
                {
                    ModelState.AddModelError("", "Invalid username or password.");
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }