mirror of
https://github.com/bitwarden/server.git
synced 2025-07-19 08:30:59 -05:00
[AC-1200] Admin Console code ownership - move OrganizationFeatures (#3369)
This commit is contained in:
@ -0,0 +1,36 @@
|
||||
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationConnections.Interfaces;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Exceptions;
|
||||
using Bit.Core.Repositories;
|
||||
|
||||
namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationConnections;
|
||||
|
||||
public class ValidateBillingSyncKeyCommand : IValidateBillingSyncKeyCommand
|
||||
{
|
||||
private readonly IOrganizationApiKeyRepository _apiKeyRepository;
|
||||
|
||||
public ValidateBillingSyncKeyCommand(
|
||||
IOrganizationApiKeyRepository organizationApiKeyRepository)
|
||||
{
|
||||
_apiKeyRepository = organizationApiKeyRepository;
|
||||
}
|
||||
|
||||
public async Task<bool> ValidateBillingSyncKeyAsync(Organization organization, string billingSyncKey)
|
||||
{
|
||||
if (organization == null)
|
||||
{
|
||||
throw new BadRequestException("Invalid organization");
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(billingSyncKey))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var orgApiKey = (await _apiKeyRepository.GetManyByOrganizationIdTypeAsync(organization.Id, Core.Enums.OrganizationApiKeyType.BillingSync)).FirstOrDefault();
|
||||
if (string.Equals(orgApiKey.ApiKey, billingSyncKey))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user