Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a problem while navigating with the manager #275

Merged
merged 1 commit into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -28,7 +28,9 @@ export class AuthGuardService implements CanActivate, CanActivateChild {
}

private checkIfCanActivate(route: ActivatedRouteSnapshot): Observable<boolean> {
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)) {
Expand Down
2 changes: 2 additions & 0 deletions static/skywire-manager-src/src/app/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export class AuthService {
if (err.originalError && (err.originalError as HttpErrorResponse).status === 401) {
return of(AuthStates.NotLogged);
}

return throwError(err);
})
);
}
Expand Down