Hi, in a project I added default security. For some reason when I try to access a private page app redirect to home and not to login page.
security.interceptor.ts is fine:
return next.handle(request).pipe(catchError((response: any) => {
if (response.status === 401) {
const redirectUrl = this.router.url;
this.router.navigate([{outlets: {popup: null}}]).then(() =>
this.router.navigate(['login'], {queryParams: {redirectUrl}})
);
response.error = {error: {message: 'Session expired.'}};
}
And app.routes.ts are fine too:
export const routes: Routes = [
{ path: '', redirectTo: '/encuesta', pathMatch: 'full' },
{
path: '',
component: MainLayoutComponent,
children: [
{
path: 'encuesta',
data: {
roles: ['Everybody'],
},
component: EncuestaComponent
},
...
{
path: '',
component: LoginLayoutComponent,
children: [
{
path: 'login',
data: {
roles: ['Everybody'],
},
component: LoginComponent
},
]
},
Whats could be wrong?
Thanks for your support.