Hi i configured this routing:
const routes: Routes = [
{
path: '',
component: LayoutComponent,
canActivateChild: [AuthGuardService],
children: [
{
path: '',
pathMatch: 'full',
redirectTo: '/buchbestellungen',
canActivate: [AuthGuardService]
},
{
path: 'buchbestellungen',
component: BuchbestellungenComponent,
canActivate: [AuthGuardService]
},
{
path: 'buchbestellungen2',
component: Buchbestellungen2Component,
canActivate: [AuthGuardService]
},
]
},
{path: 'login', component: LoginComponent},
{path: '**', component: NotFoundComponent}
];
I dont want to take care of the name of the login page an not if that is the target page after logout in future. So after logout is done logout component redirects to the startpage.
For now, ther is no startpage component (later, there may be a dashboard) but a redirectTo the "buchbestellungen" route if you authenticated. If you are not logged in, visiting the start-page redirects to /buchbestellungen and the auth-guard service redirects to login route.
This works perferct from every route (e.g. buchbestellungen2), but not, when i log out while i'm on /buchbestellungen. This redirects to "/" and then back to buchbestellungen. But the auth-guard is not invoked (i have a Console.log() in the canActivate() method, but it's also not invoked).
Example 1: buchbestellungen2 -> logout() -> redirects to / -> redirects to /buchbestellungen an intercepted by auth-guard i end on the /login route
Example 2: buchbestellungen -> logout() -> redirects to / -> redirects to /buchbestellungen (no auth-guard and no redirect to /login)
Is it possible, that the router dont invoke the auth-guard, because i am comming from /buchbestellungen an this rout is already authenticated? Is there any possibility to force the router to invoke the guard?
Thanks