mirror of
https://github.com/bitwarden/server.git
synced 2025-02-18 02:11:22 +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;
|
StripeCustomer customer = null;
|
||||||
StripeSubscription subscription = 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
|
customer = await customerService.CreateAsync(new StripeCustomerCreateOptions
|
||||||
{
|
{
|
||||||
@ -245,6 +254,12 @@ namespace Bit.Core.Services
|
|||||||
throw new BadRequestException("Already accepted.");
|
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;
|
var tokenValidationFailed = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user