From 6fcb14dc80be97338817cc60a9cf2182ac44d557 Mon Sep 17 00:00:00 2001 From: Senyoret1 <34079003+Senyoret1@users.noreply.github.com> Date: Sat, 28 Mar 2020 17:33:47 -0400 Subject: [PATCH] Fix a problem while navigating with the manager --- .../src/app/services/auth-guard.service.ts | 8 +++++--- .../skywire-manager-src/src/app/services/auth.service.ts | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/static/skywire-manager-src/src/app/services/auth-guard.service.ts b/static/skywire-manager-src/src/app/services/auth-guard.service.ts index 869828e238..d7a0fa63b3 100644 --- a/static/skywire-manager-src/src/app/services/auth-guard.service.ts +++ b/static/skywire-manager-src/src/app/services/auth-guard.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, CanActivateChild } from '@angular/router'; -import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; +import { Observable, of } from 'rxjs'; +import { map, catchError } from 'rxjs/operators'; import { MatDialog } from '@angular/material/dialog'; import { AuthService, AuthStates } from './auth.service'; @@ -28,7 +28,9 @@ export class AuthGuardService implements CanActivate, CanActivateChild { } private checkIfCanActivate(route: ActivatedRouteSnapshot): Observable { - return this.authService.checkLogin().pipe(map((authState: AuthStates) => { + return this.authService.checkLogin().pipe(catchError(() => { + return of(AuthStates.AuthDisabled); + }), map((authState: AuthStates) => { // If the user is trying to access "Login" page while he is already logged in or the // auth is disabled, redirect him to "Nodes" page if (route.routeConfig.path === 'login' && (authState === AuthStates.Logged || authState === AuthStates.AuthDisabled)) { diff --git a/static/skywire-manager-src/src/app/services/auth.service.ts b/static/skywire-manager-src/src/app/services/auth.service.ts index 2ee86db125..aae15c62c7 100644 --- a/static/skywire-manager-src/src/app/services/auth.service.ts +++ b/static/skywire-manager-src/src/app/services/auth.service.ts @@ -57,6 +57,8 @@ export class AuthService { if (err.originalError && (err.originalError as HttpErrorResponse).status === 401) { return of(AuthStates.NotLogged); } + + return throwError(err); }) ); }