public ActionResult Login(string username, string password) { Account account = _userManager.Find(username, password); if (account == null) { return(HttpNotFound()); } // success var ident = _userManager.CreateIdentity(account, DefaultAuthenticationTypes.ApplicationCookie); //use the instance that has been created. var authManager = HttpContext.GetOwinContext().Authentication; authManager.SignIn( new AuthenticationProperties { IsPersistent = false }, ident); return(Redirect("/Home")); }
private Task<IEnumerable<Claim>> validationCallback(string userName, string password) { using (DbContext dbContext = MyCtx.Create()) using (MyUserStore userStore = new MyUserStore(dbContext)) using (MyUserManager userManager = new MyUserManager(userStore)) { var user = userManager.FindByName(userName); if (user == null) { return null; } if (!userManager.CheckPassword(user, password)) { return null; } ClaimsIdentity claimsIdentity = userManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); return Task.FromResult(claimsIdentity.Claims); } }