1
0
mirror of https://github.com/bitwarden/server.git synced 2025-03-12 13:29:14 +01:00

Scale seats before inserting ProviderOrganization when adding existing organization (#5420)

This commit is contained in:
Alex Morask 2025-02-19 12:01:11 -05:00 committed by GitHub
parent 4f73081e41
commit 228ce3b2e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -111,10 +111,15 @@ public class ProviderBillingService(
Key = key
};
/*
* We have to scale the provider's seats before the ProviderOrganization
* row is inserted so the added organization's seats don't get double counted.
*/
await ScaleSeats(provider, organization.PlanType, organization.Seats!.Value);
await Task.WhenAll(
organizationRepository.ReplaceAsync(organization),
providerOrganizationRepository.CreateAsync(providerOrganization),
ScaleSeats(provider, organization.PlanType, organization.Seats!.Value)
providerOrganizationRepository.CreateAsync(providerOrganization)
);
var clientCustomer = await subscriberService.GetCustomer(organization);