private async Task <List <Claim> > GetUserClaims(ApplicationUser user) { List <Claim> claims = new List <Claim>() { new Claim(ClaimTypes.NameIdentifier, user.UserName), new Claim(ClaimTypes.Name, user.UserName), new Claim(ClaimTypes.Email, user.Email) }; var userClaims = await userManager.GetClaimsAsync(user); if (userClaims != null) { claims.AddRange(userClaims); } // Add roles var userRoles = await userManager.GetRolesAsync(user); if (userRoles != null) { foreach (var userRole in userRoles) { claims.Add(new Claim(ClaimTypes.Role, userRole)); // Add role claims claims.AddRange(await rolesService.GetClaimsForRole(userRole)); } } return(claims); }