Interface IRoleService
- Namespace
- Htmx.Components.Services
- Assembly
- Htmx.Components.dll
Provides role-based authorization services for checking user permissions.
public interface IRoleService
- Extension Methods
Remarks
This service abstracts role-based authorization logic and can be implemented to integrate with various authorization systems such as ASP.NET Core Identity, custom role providers, or external authorization services.
Methods
UserHasAnyRoleAsync(ClaimsPrincipal, IEnumerable<string>)
Determines whether the user has at least one of the specified roles.
Task<bool> UserHasAnyRoleAsync(ClaimsPrincipal user, IEnumerable<string> requiredRoles)
Parameters
user
ClaimsPrincipalThe claims principal representing the user.
requiredRoles
IEnumerable<string>The collection of roles to check against.
Returns
- Task<bool>
A task that represents the asynchronous operation. The task result is true if the user has at least one of the required roles; otherwise, false.
Exceptions
- ArgumentNullException
Thrown when
user
orrequiredRoles
is null.