RoleGuardWidget
Component Detail
User Interface
medium complexity
Shared Component
frontendmobile
0
Dependencies
0
Dependents
1
Entities
0
Integrations
Description
Client-side gate widget that conditionally renders navigation items, screens, and action controls based on the role context returned at session bootstrap. It consumes the role context from the session store and suppresses UI surfaces the current role is not permitted to access. On mobile it applies the Organization Admin → Coordinator surface-mapping rule before rendering.
role-guard-widget
Sources & reasoning
Lines 256-259 define all four roles with explicit access boundaries, and line 322 names mobile role profiles as an MVP deliverable. RBAC is listed in the Fase 1 MVP scope and is a structural prerequisite for module toggles, multi-tenancy, and audit logging, making it critical and must_have at MVP.
-
docs/source/likeperson.md · line 256-259Peer Mentor (Likeperson): Creates and tracks activities and follow-ups. Logs in to the Mobile App only.
-
docs/source/likeperson.md · line 3222 mobilrolle-profiler: Peer Mentor, Coordinator (Organization Admins logger på som Coordinator i app-konteksten)
Responsibilities
- Reads role context from session store and exposes it to child components
- Conditionally renders or hides navigation entries, screens, and action buttons per role rules
- Applies the OrgAdmin-as-Coordinator mobile surface mapping before evaluating visibility
- Redirects or shows an access-denied state when a protected route is accessed without the required role
Interfaces
RoleGuardWidget({ requiredRole, children }): ReactNode
useRoleContext(): RoleContext
canAccess(role: Role, resource: string): boolean