mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 00:22:50 -05:00
Fix Organization License Sync (#2864)
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Data.Organizations;
|
||||
using Bit.Core.Repositories;
|
||||
@ -197,22 +198,14 @@ public class OrganizationRepository : Repository<Core.Entities.Organization, Org
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var organization = await GetDbSet(dbContext).FindAsync(id);
|
||||
if (organization == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var selfHostOrganization = Mapper.Map<SelfHostedOrganizationDetails>(organization);
|
||||
var selfHostedOrganization = await dbContext.Organizations
|
||||
.Where(o => o.Id == id)
|
||||
.AsSplitQuery()
|
||||
.ProjectTo<SelfHostedOrganizationDetails>(Mapper.ConfigurationProvider)
|
||||
.SingleOrDefaultAsync();
|
||||
|
||||
selfHostOrganization.OccupiedSeatCount =
|
||||
organization.OrganizationUsers.Count(ou => ou.Status >= OrganizationUserStatusType.Invited);
|
||||
selfHostOrganization.CollectionCount = organization.Collections?.Count ?? 0;
|
||||
selfHostOrganization.GroupCount = organization?.Groups.Count ?? 0;
|
||||
selfHostOrganization.SsoConfig = organization.SsoConfigs.SingleOrDefault();
|
||||
selfHostOrganization.ScimConnections = organization.Connections.Where(c => c.Type == OrganizationConnectionType.Scim);
|
||||
|
||||
return selfHostOrganization;
|
||||
return selfHostedOrganization;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user