1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-05 10:40:30 -05:00
bitwarden/src/Api/AdminConsole/Authorization/Requirements/ManageAccountRecoveryRequirement.cs
Brandon Treston 28467fc8f6
[PM-20092] Refactor OrganizationUsersController Get to return account recovery users (#5756)
* wip

* wip

* add dict conversion to Get

* wip

* clean up

* clean up

* continue refactor

* Fix feature flag

Co-authored-by: Rui Tomé <108268980+r-tome@users.noreply.github.com>

---------

Co-authored-by: Rui Tomé <108268980+r-tome@users.noreply.github.com>
2025-05-06 13:45:05 -04:00

21 lines
635 B
C#

#nullable enable
using Bit.Core.Context;
using Bit.Core.Enums;
namespace Bit.Api.AdminConsole.Authorization.Requirements;
public class ManageAccountRecoveryRequirement : IOrganizationRequirement
{
public async Task<bool> AuthorizeAsync(
CurrentContextOrganization? organizationClaims,
Func<Task<bool>> isProviderUserForOrg)
=> organizationClaims switch
{
{ Type: OrganizationUserType.Owner } => true,
{ Type: OrganizationUserType.Admin } => true,
{ Permissions.ManageResetPassword: true } => true,
_ => await isProviderUserForOrg()
};
}