Naive demonstration of Multi-Role Routing in NextJs with Guard Approach.
This example demonstrates a role-based access control system with four distinct user roles:
- Admin
- Care-Provider
- Client (Referred)
- Client (Not Referred)
The system includes a table that defines which routes (pages) are accessible to each user role. Users can switch between different roles and navigate to various pages to see how permissions change based on their current role. The access control is implemented using an AuthorizationGuard component. This guard is wrapped around the layout file and serves as the decision-making mechanism. It determines whether a particular role should be allowed access to a specific page or not.