mirror of
https://github.com/bitwarden/server.git
synced 2024-11-26 12:55:17 +01:00
limit org admins to 1 free organization
This commit is contained in:
parent
02d8913a77
commit
b4d588d981
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user