Exemplo n.º 1
0
        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);
            }
        }