diff --git a/src/Core/Services/Implementations/OrganizationService.cs b/src/Core/Services/Implementations/OrganizationService.cs index efbe91b1ea..e0f7f3e3e3 100644 --- a/src/Core/Services/Implementations/OrganizationService.cs +++ b/src/Core/Services/Implementations/OrganizationService.cs @@ -87,7 +87,16 @@ namespace Bit.Core.Services StripeCustomer customer = null; StripeSubscription subscription = null; - if(plan.Type != Enums.PlanType.Free) + if(plan.Type == Enums.PlanType.Free) + { + var ownerExistingOrgs = await _organizationUserRepository.GetManyByUserAsync(signup.Owner.Id); + if(ownerExistingOrgs.Any(ou => ou.Type == Enums.OrganizationUserType.Owner || + ou.Type == Enums.OrganizationUserType.Admin)) + { + throw new BadRequestException("You can only be an admin of 1 free organization."); + } + } + else { customer = await customerService.CreateAsync(new StripeCustomerCreateOptions { @@ -245,6 +254,12 @@ namespace Bit.Core.Services throw new BadRequestException("Already accepted."); } + var existingOrgs = await _organizationUserRepository.GetManyByUserAsync(user.Id); + if(existingOrgs.Any(ou => ou.Type == Enums.OrganizationUserType.Owner || ou.Type == Enums.OrganizationUserType.Admin)) + { + throw new BadRequestException("You can only be an admin of 1 free organization."); + } + var tokenValidationFailed = true; try {