diff --git a/javascript/apps/taiga/src/app/shared/api-rest-interceptor/api-rest-interceptor.service.spec.ts b/javascript/apps/taiga/src/app/shared/api-rest-interceptor/api-rest-interceptor.service.spec.ts index 9311de7eb..71f02c60a 100644 --- a/javascript/apps/taiga/src/app/shared/api-rest-interceptor/api-rest-interceptor.service.spec.ts +++ b/javascript/apps/taiga/src/app/shared/api-rest-interceptor/api-rest-interceptor.service.spec.ts @@ -125,6 +125,7 @@ describe('ApiRestInterceptor', () => { const authService = spectator.inject(AuthService); authService.getAuth.mockReturnValue({ token, refresh }); + authService.isLogged.mockReturnValue(true); const authInterceptorService = spectator.inject(ApiRestInterceptorService); const apiRequest = new HttpRequest('GET', ConfigServiceMock.apiUrl); diff --git a/javascript/apps/taiga/src/app/shared/api-rest-interceptor/api-rest-interceptor.service.ts b/javascript/apps/taiga/src/app/shared/api-rest-interceptor/api-rest-interceptor.service.ts index a66949821..4e73b83cb 100644 --- a/javascript/apps/taiga/src/app/shared/api-rest-interceptor/api-rest-interceptor.service.ts +++ b/javascript/apps/taiga/src/app/shared/api-rest-interceptor/api-rest-interceptor.service.ts @@ -78,7 +78,10 @@ export class ApiRestInterceptorService implements HttpInterceptor { (!auth?.token || !auth?.refresh) && !request.url.includes('/auth/token') ) { - void this.router.navigate(['/logout']); + if (this.authService.isLogged()) { + void this.router.navigate(['/logout']); + } + return EMPTY; } } @@ -145,7 +148,9 @@ export class ApiRestInterceptorService implements HttpInterceptor { catchError((err: HttpErrorResponse) => { this.refreshTokenInProgress = false; - void this.router.navigate(['/logout']); + if (this.authService.isLogged()) { + void this.router.navigate(['/logout']); + } return throwError(() => err); })