1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-04 20:50:21 -05:00

use generics instead

This commit is contained in:
Thomas Rittson 2025-03-21 14:02:47 +10:00
parent b5d1c3d2b4
commit a0ac86888d
No known key found for this signature in database
GPG Key ID: CDDDA03861C35E27
2 changed files with 4 additions and 3 deletions

View File

@ -146,7 +146,7 @@ public class OrganizationUsersController : Controller
}
[HttpGet("")]
[OrganizationAuthorize(typeof(ManageUsersRequirement))]
[OrganizationAuthorize<ManageUsersRequirement>]
public async Task<ListResponseModel<OrganizationUserUserDetailsResponseModel>> Get(Guid orgId, bool includeGroups = false, bool includeCollections = false)
{
var organizationUsers = await _organizationUserUserDetailsQuery.GetOrganizationUserUserDetails(

View File

@ -2,12 +2,13 @@
namespace Bit.Core.AdminConsole.OrganizationFeatures.Shared.Authorization;
public class OrganizationAuthorizeAttribute(Type requirementType)
public class OrganizationAuthorizeAttribute<T>
: AuthorizeAttribute, IAuthorizationRequirementData
where T : IOrganizationRequirement, new()
{
public IEnumerable<IAuthorizationRequirement> GetRequirements()
{
var requirement = (IOrganizationRequirement)Activator.CreateInstance(requirementType)!;
var requirement = new T();
yield return requirement;
}
}