Search Results for

    Show / Hide Table of Contents

    Class RoleService

    Service for determining user roles and permissions in the application.

    Inheritance
    object
    RoleService
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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:

    • true: User is authenticated and has admin privileges
    • false: User is authenticated but does not have admin privileges
    • null: User is not authenticated or user information could not be retrieved
    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:

    • true: User is authenticated and has designer privileges
    • false: User is authenticated but does not have designer privileges
    • null: User is not authenticated or user/organization information could not be retrieved
    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:

    • true: User is authenticated and has organization admin privileges
    • false: User is authenticated but does not have organization admin privileges
    • null: User is not authenticated or user/organization information could not be retrieved
    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:

    • true: User is authenticated and has organizer privileges
    • false: User is authenticated but does not have organizer privileges
    • null: User is not authenticated or user/organization information could not be retrieved
    Remarks

    Organizers can create and manage events within their organization.

    In this article
    Back to top Generated by DocFX