private async Task <ClaimsPrincipal> getClaims(CustomerSite user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } var userId = await _myUserManager.GetUserIdAsync(user); var userName = await _myUserManager.GetUserNameAsync(user); var id = new ClaimsIdentity(); id.AddClaim(new Claim(JwtClaimTypes.Id, userId)); id.AddClaim(new Claim(JwtClaimTypes.PreferredUserName, userName)); var roles = await _myUserManager.GetRolesAsync(user); foreach (var roleName in roles) { id.AddClaim(new Claim(JwtClaimTypes.Role, roleName)); } id.AddClaims(await _myUserManager.GetClaimsAsync(user)); return(new ClaimsPrincipal(id)); }