Redirect to login doesn't work

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.

Hi @Carlos_Carminati,

Indeed everything looks correct and should have worked. Could you check if the Home page isn't by any chance set as the login page (use the page properties to verify that)?

Login page was marked as Login page. That's not the problem.

image

I am afraid we cannot reproduce such behavior in a local application. We will need to reproduce the problem in order to troubleshoot further. You can send us a runnable version of your application to info@radzen.com and we will check it out.