1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-15 14:47:45 -05:00

Fix logic and apply to controller

This commit is contained in:
Thomas Rittson
2025-03-26 15:14:58 +10:00
parent 3d564e7658
commit 74f45a18ae
3 changed files with 17 additions and 13 deletions

View File

@ -0,0 +1,15 @@
#nullable enable
using Bit.Core.AdminConsole.OrganizationFeatures.Shared.Authorization;
using Bit.Core.Context;
namespace Bit.Core.AdminConsole.OrganizationFeatures;
/// <summary>
/// Requires that the user is a member of the organization or a provider for the organization.
/// </summary>
public class MemberOrProviderRequirement : IOrganizationRequirement
{
public async Task<bool> AuthorizeAsync(Guid organizationId, CurrentContextOrganization? organizationClaims, ICurrentContext currentContext)
=> organizationClaims is not null || await currentContext.ProviderUserForOrgAsync(organizationId);
}

View File

@ -1,12 +0,0 @@
#nullable enable
using Bit.Core.AdminConsole.OrganizationFeatures.Shared.Authorization;
using Bit.Core.Context;
namespace Bit.Core.AdminConsole.OrganizationFeatures;
public class OrganizationMemberRequirement : IOrganizationRequirement
{
public Task<bool> AuthorizeAsync(Guid organizationId, CurrentContextOrganization? organizationClaims, ICurrentContext currentContext)
=> Task.FromResult(organizationClaims is not null);
}