1
0
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:
Thomas Rittson
2023-10-27 07:47:44 +10:00
committed by GitHub
parent 26dd8b0e47
commit ad230fb6a5
66 changed files with 151 additions and 152 deletions

View File

@ -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;
}
}