1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-04 01:22:50 -05:00

api get generating organization license

This commit is contained in:
Kyle Spearrin
2017-08-14 22:16:30 -04:00
parent 63a82336c6
commit abf68c1cea
3 changed files with 30 additions and 4 deletions

View File

@ -24,6 +24,7 @@ namespace Bit.Api.Controllers
private readonly IOrganizationUserRepository _organizationUserRepository;
private readonly IOrganizationService _organizationService;
private readonly IUserService _userService;
private readonly ILicensingService _licensingService;
private readonly CurrentContext _currentContext;
private readonly GlobalSettings _globalSettings;
private readonly UserManager<User> _userManager;
@ -33,6 +34,7 @@ namespace Bit.Api.Controllers
IOrganizationUserRepository organizationUserRepository,
IOrganizationService organizationService,
IUserService userService,
ILicensingService licensingService,
CurrentContext currentContext,
GlobalSettings globalSettings,
UserManager<User> userManager)
@ -43,6 +45,7 @@ namespace Bit.Api.Controllers
_userService = userService;
_currentContext = currentContext;
_userManager = userManager;
_licensingService = licensingService;
_globalSettings = globalSettings;
}
@ -95,6 +98,24 @@ namespace Bit.Api.Controllers
}
}
[HttpGet("{id}/license")]
public async Task<OrganizationLicense> GetLicense(string id, [FromQuery]Guid installationId)
{
var orgIdGuid = new Guid(id);
if(!_currentContext.OrganizationOwner(orgIdGuid))
{
throw new NotFoundException();
}
var organization = await _organizationRepository.GetByIdAsync(orgIdGuid);
if(organization == null)
{
throw new NotFoundException();
}
return new OrganizationLicense(organization, installationId, _licensingService);
}
[HttpGet("")]
public async Task<ListResponseModel<OrganizationResponseModel>> GetUser()
{