mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 00:22:50 -05:00
[Provider] Create and access child organizations (#1427)
This commit is contained in:
@ -51,7 +51,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task<OrganizationResponseModel> Get(string id)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationOwner(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationOwner(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -70,7 +70,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task<BillingResponseModel> GetBilling(string id)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationOwner(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationOwner(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -89,7 +89,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task<OrganizationSubscriptionResponseModel> GetSubscription(string id)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationOwner(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationOwner(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -120,7 +120,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task<OrganizationLicense> GetLicense(string id, [FromQuery]Guid installationId)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationOwner(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationOwner(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -154,12 +154,6 @@ namespace Bit.Api.Controllers
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
|
||||
var plan = StaticStore.Plans.FirstOrDefault(plan => plan.Type == model.PlanType);
|
||||
if (plan == null || plan.LegacyYear != null)
|
||||
{
|
||||
throw new Exception("Invalid plan selected.");
|
||||
}
|
||||
|
||||
var organizationSignup = model.ToOrganizationSignup(user);
|
||||
var result = await _organizationService.SignUpAsync(organizationSignup);
|
||||
return new OrganizationResponseModel(result.Item1);
|
||||
@ -191,7 +185,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task<OrganizationResponseModel> Put(string id, [FromBody]OrganizationUpdateRequestModel model)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationOwner(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationOwner(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -214,7 +208,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task PostPayment(string id, [FromBody]PaymentRequestModel model)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationOwner(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationOwner(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -237,7 +231,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task<PaymentResponseModel> PostUpgrade(string id, [FromBody]OrganizationUpgradeRequestModel model)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationOwner(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationOwner(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -255,7 +249,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task<PaymentResponseModel> PostSeat(string id, [FromBody]OrganizationSeatRequestModel model)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationOwner(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationOwner(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -273,7 +267,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task<PaymentResponseModel> PostStorage(string id, [FromBody]StorageRequestModel model)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationOwner(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationOwner(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -291,7 +285,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task PostVerifyBank(string id, [FromBody]OrganizationVerifyBankRequestModel model)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationOwner(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationOwner(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -304,7 +298,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task PostCancel(string id)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationOwner(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationOwner(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -317,7 +311,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task PostReinstate(string id)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationOwner(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationOwner(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -329,7 +323,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task Leave(string id)
|
||||
{
|
||||
var orgGuidId = new Guid(id);
|
||||
if (!_currentContext.OrganizationUser(orgGuidId))
|
||||
if (!await _currentContext.OrganizationUser(orgGuidId))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -343,7 +337,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task Delete(string id, [FromBody]OrganizationDeleteRequestModel model)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationOwner(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationOwner(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -376,7 +370,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task PostLicense(string id, LicenseRequestModel model)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationOwner(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationOwner(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -400,7 +394,7 @@ namespace Bit.Api.Controllers
|
||||
}
|
||||
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationAdmin(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationAdmin(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -419,7 +413,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task<ApiKeyResponseModel> ApiKey(string id, [FromBody]ApiKeyRequestModel model)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationOwner(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationOwner(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -452,7 +446,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task<ApiKeyResponseModel> RotateApiKey(string id, [FromBody]ApiKeyRequestModel model)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationOwner(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationOwner(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -487,7 +481,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task<TaxInfoResponseModel> GetTaxInfo(string id)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationOwner(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationOwner(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
@ -507,7 +501,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task PutTaxInfo(string id, [FromBody]OrganizationTaxInfoUpdateRequestModel model)
|
||||
{
|
||||
var orgIdGuid = new Guid(id);
|
||||
if (!_currentContext.OrganizationOwner(orgIdGuid))
|
||||
if (!await _currentContext.OrganizationOwner(orgIdGuid))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
Reference in New Issue
Block a user