1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-16 10:38:17 -05:00

Use switch expression instead of boolean

Co-authored-by:  Audrey  <ajensen@bitwarden.com>
This commit is contained in:
Thomas Rittson 2025-04-09 10:33:31 +10:00 committed by GitHub
parent 6f1866d7b7
commit 8977cac0f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,11 +7,14 @@ namespace Bit.Api.AdminConsole.Authorization.Requirements;
public class ManageUsersRequirement : IOrganizationRequirement
{
public async Task<bool> AuthorizeAsync(
CurrentContextOrganization? organizationClaims,
Func<Task<bool>> isProviderUserForOrg)
=> organizationClaims is
{ Type: OrganizationUserType.Owner or OrganizationUserType.Admin } or
{ Permissions.ManageUsers: true }
|| await isProviderUserForOrg();
public async Task<bool> AuthorizeAsync(
CurrentContextOrganization? organizationClaims,
Func<Task<bool>> isProviderUserForOrg)
=> organizationClaims switch
{
{ Type: OrganizationUserType.Owner } => true,
{ Type: OrganizationUserType.Admin } => true,
{ Permissions.ManageUsers: true } => true,
_ => await isProviderUserForOrg()
};
}