public async Task GetProfileDataAsync(ProfileDataRequestContext context)
        {
            var userId = Guid.Parse(context.Subject.GetSubjectId());

            var(userResult, user) = await tenantUserService.FindByIdAsync(userId).UnpackSingleOrDefault();

            var principal = await claimsFactory.CreateAsync(user);

            var claims = principal.Claims
                         .Where(x => context.RequestedClaimTypes.Contains(x.Type));

            var tenants = await tenantService.Search(new TenantSearch { Hostname = configuration.Hostname });

            if (!tenants.Any())
            {
                throw new Exception("Host not recognized!");
            }

            var tenantId = tenants.First().TenantId;
            var roles    = await tenantUserService.GetRolesAsync(userId, tenantId);

            var tenantRoles = roles.Select(x => new Claim(ClaimTypes.Role, x.NormalizedName));

            context.IssuedClaims = claims.Union(tenantRoles).ToList();
            context.IssuedClaims.Add(new Claim("userId", userId.ToString()));
        }
 public virtual async Task <IdentityUtilsResult <TTenantDto> > Search([FromBody] TenantSearch tenantSearchRequest)
 {
     return(IdentityUtilsResult <TTenantDto> .SuccessResult(await tenantService.Search(tenantSearchRequest)));
 }