Exemplo n.º 1
0
        public async Task <ClaimsIdentity> GenerateUserIdentityAsync(UserManager <ApplicationUser> manager)
        {
            // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
            var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);

            // Add custom user claims here
            dbProjectMSEntities projectDb = new dbProjectMSEntities();
            var  userResult = from u in projectDb.Users where u.Email.Equals(Email) select u;
            User user       = userResult.Single();

            userIdentity.AddClaim(new Claim("UserId", Convert.ToString(user.UserID)));
            return(userIdentity);
        }