The user does not have access until they login.
To immediately redirect all users to the login page instead you can implement a canActivate
guard for your Admin routes.
Change your admin-routing.module.ts to this (notice the addition of canActivate: [AuthGuard]
):
const adminRoutes: Routes = [
{
path: 'admin',
component: AdminComponent,
children: [
{ path: 'users', component: UserListComponent, canActivate: [AuthGuard], data: { title: "Admin | Users" } },
{ path: 'roles', component: RoleListComponent, canActivate: [AuthGuard], data: { title: "Admin | Roles" } }
]
}
];
The user does not have access until they login.
To immediately redirect all users to the login page instead you can implement a canActivate
guard for your Admin routes.
Change your admin-routing.module.ts to this (notice the addition of canActivate: [AuthGuard]
):
const adminRoutes: Routes = [
{
path: 'admin',
component: AdminComponent,
children: [
{ path: 'users', component: UserListComponent, canActivate: [AuthGuard], data: { title: "Admin | Users" } },
{ path: 'roles', component: RoleListComponent, canActivate: [AuthGuard], data: { title: "Admin | Roles" } }
]
}
];