Class RoleService
Service for determining user roles and permissions in the application.
Inherited Members
Namespace: OEMS.UI.Auth
Assembly: OEMS.UI.dll
Syntax
public class RoleService
Remarks
This service provides methods to check various role-based permissions for the currently authenticated user, such as organization admin status, organizer rights, designer capabilities, and system administration privileges.
Constructors
RoleService(AuthenticationStateProvider, IUserService, IDbContextFactory<OEMSDBContext>, ILogger<RoleService>)
Initializes a new instance of the RoleService class.
Declaration
public RoleService(AuthenticationStateProvider authProvider, IUserService userService, IDbContextFactory<OEMSDBContext> contextFactory, ILogger<RoleService> logger)
Parameters
Type | Name | Description |
---|---|---|
AuthenticationStateProvider | authProvider | Authentication state provider for accessing the current user |
IUserService | userService | User service for retrieving user and role information |
IDbContextFactory<OEMSDBContext> | contextFactory | DbContext factory for creating separate contexts to avoid concurrency issues |
ILogger<RoleService> | logger |
Methods
ClearUserRoleCache(Guid, Guid)
Clears the role cache for a specific user in an organization. This should be called after role changes to ensure updated permissions are reflected immediately.
Declaration
public void ClearUserRoleCache(Guid userId, Guid organizationId)
Parameters
Type | Name | Description |
---|---|---|
Guid | userId | The user ID whose roles were changed |
Guid | organizationId | The organization ID where the role change occurred |
IsUserAdminAsync()
Determines if the currently authenticated user has system administrator privileges.
Declaration
public Task<bool?> IsUserAdminAsync()
Returns
Type | Description |
---|---|
Task<bool?> | A nullable boolean indicating the user's admin status:
|
Remarks
This method checks the IsAdmin property on the User entity to determine system-wide administrative privileges. System administrators can perform operations like creating new organizations and managing system-wide settings.
IsUserDesignerAsync()
Determines if the currently authenticated user has designer privileges.
Declaration
public Task<bool?> IsUserDesignerAsync()
Returns
Type | Description |
---|---|
Task<bool?> | A nullable boolean indicating the user's designer status:
|
Remarks
Designers can create and modify templates for events, processes, and communications.
IsUserOrgAdminAsync()
Determines if the currently authenticated user has organization admin privileges.
Declaration
public Task<bool?> IsUserOrgAdminAsync()
Returns
Type | Description |
---|---|
Task<bool?> | A nullable boolean indicating the user's organization admin status:
|
Remarks
Organization admins can manage users and settings within their specific organization.
IsUserOrganizerAsync()
Determines if the currently authenticated user has organizer privileges.
Declaration
public Task<bool?> IsUserOrganizerAsync()
Returns
Type | Description |
---|---|
Task<bool?> | A nullable boolean indicating the user's organizer status:
|
Remarks
Organizers can create and manage events within their organization.