1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 05:00:19 -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("")] [HttpGet("")]
[OrganizationAuthorize(typeof(ManageUsersRequirement))] [OrganizationAuthorize<ManageUsersRequirement>]
public async Task<ListResponseModel<OrganizationUserUserDetailsResponseModel>> Get(Guid orgId, bool includeGroups = false, bool includeCollections = false) public async Task<ListResponseModel<OrganizationUserUserDetailsResponseModel>> Get(Guid orgId, bool includeGroups = false, bool includeCollections = false)
{ {
var organizationUsers = await _organizationUserUserDetailsQuery.GetOrganizationUserUserDetails( var organizationUsers = await _organizationUserUserDetailsQuery.GetOrganizationUserUserDetails(

View File

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