From 5acbfe27ea37b71910c3366a1ea2bfba8dcb21b8 Mon Sep 17 00:00:00 2001 From: Giuseppe <giuseppe.digilio@gmail.com> Date: Fri, 2 Nov 2018 13:30:04 +0100 Subject: [PATCH] Added more checks on redirect when token has expired --- src/app/core/auth/auth.interceptor.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/core/auth/auth.interceptor.ts b/src/app/core/auth/auth.interceptor.ts index f38abb90bc..9cc77c9df6 100644 --- a/src/app/core/auth/auth.interceptor.ts +++ b/src/app/core/auth/auth.interceptor.ts @@ -14,7 +14,7 @@ import { AppState } from '../../app.reducer'; import { AuthService } from './auth.service'; import { AuthStatus } from './models/auth-status.model'; import { AuthTokenInfo } from './models/auth-token-info.model'; -import { isNotEmpty, isUndefined } from '../../shared/empty.util'; +import { isNotEmpty, isUndefined, isNotNull } from '../../shared/empty.util'; import { RedirectWhenTokenExpiredAction, RefreshTokenAction } from './auth.actions'; import { Store } from '@ngrx/store'; import { Router } from '@angular/router'; @@ -139,7 +139,7 @@ export class AuthInterceptor implements HttpInterceptor { url: error.url }); return Observable.of(authResponse); - } else if (this.isUnauthorized(error)) { + } else if (this.isUnauthorized(error) && isNotNull(token) && authService.isTokenExpired()) { // The access token provided is expired, revoked, malformed, or invalid for other reasons // Redirect to the login route this.store.dispatch(new RedirectWhenTokenExpiredAction('auth.messages.expired')); -- GitLab