1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-25 12:45:18 +01:00

limit org admins to 1 free organization

This commit is contained in:
Kyle Spearrin 2017-04-07 14:03:36 -04:00
parent 02d8913a77
commit b4d588d981

View File

@ -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
{