Role-Based Authentication
The system ensures only authorized users can access specific routes based on their assigned roles.
The main routing file defines route paths and lazy-loaded modules for various components based on the user's role.
...
{
path: '',
component: AdminLayout,
canActivateChild: [AuthGuardChild],
children: [
{
path: 'dashboard',
loadChildren: () => import('./demo/dashboard/dashboard.module').then((m) => m.DashboardModule),
data: { roles: [Role.Admin, Role.User] }
},
{
path: 'widget/statistics',
loadComponent: () => import('./demo/widget/statistics/statistics.component').then((c) => c.StatisticsComponent),
data: {
roles: [Role.Admin, Role.User]
}
},
]
}
...Child Routing Module: Defines the child routes and applies role-based access.
Role Management
Authentication Guard: This
AuthGuardChildensures that users can only access authorized routes.