public ActionResult Login(LoginModel model, string returnUrl)
        {
            using (var store = new UserStore<IdentityUser>(new IdentityDbContext()))
            {
                using(var manager = new UserManager<IdentityUser>(store))
                {
                    var claimsUser = manager.Find(model.UserName, model.Password);
                    if (claimsUser != null)
                    {
                        Authenticate(manager, claimsUser);
                        return RedirectToLocal(returnUrl);
                    }
                };
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return View(model);
        }
Example #2
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                return RedirectToLocal(returnUrl);
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return View(model);
        }