Frontend
RBAC (Role-Based Access Control)
Permission system for controlling access to features and UI elements
Overview
The RBAC system controls access to features based on user roles. It's implemented in @/lib/auth and provides both programmatic checks and React components for UI gating.
Roles
Four roles are defined in the system:
| Role | Description |
|---|---|
ADMIN | Full system access, can manage all resources |
EMPLOYER | Can post jobs, manage trials, review applications |
TALENT | Can apply to jobs, participate in trials |
GUEST | Read-only access to public job listings |
Permissions
Permissions are granular access rights:
Role-Permission Mapping
Permission Functions
Check Single Permission
Check All Permissions
Check Any Permission
Get All Permissions
React Guard Components
HasPermission
Renders children only if user has the specified permission:
HasAnyPermission
Renders if user has any of the specified permissions:
HasRole
Renders if user has one of the specified roles:
RequireAuth
Renders only if user is authenticated:
Auth Context Integration
Guards use the AuthContext to get the current user:
HOC Pattern
For class components or route protection:
Backend Enforcement
While frontend guards provide UI gating, the backend must also enforce permissions:
Best Practices
- Always check on backend - Frontend guards are for UX, not security
- Use specific permissions - Prefer
jobs:writeover role checks - Provide fallbacks - Show appropriate UI when access is denied
- Handle loading states - Don't flash content during auth checks