mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
Added more checks on redirect when token has expired
This commit is contained in:
@@ -14,7 +14,7 @@ import { AppState } from '../../app.reducer';
|
|||||||
import { AuthService } from './auth.service';
|
import { AuthService } from './auth.service';
|
||||||
import { AuthStatus } from './models/auth-status.model';
|
import { AuthStatus } from './models/auth-status.model';
|
||||||
import { AuthTokenInfo } from './models/auth-token-info.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 { RedirectWhenTokenExpiredAction, RefreshTokenAction } from './auth.actions';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
@@ -139,7 +139,7 @@ export class AuthInterceptor implements HttpInterceptor {
|
|||||||
url: error.url
|
url: error.url
|
||||||
});
|
});
|
||||||
return Observable.of(authResponse);
|
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
|
// The access token provided is expired, revoked, malformed, or invalid for other reasons
|
||||||
// Redirect to the login route
|
// Redirect to the login route
|
||||||
this.store.dispatch(new RedirectWhenTokenExpiredAction('auth.messages.expired'));
|
this.store.dispatch(new RedirectWhenTokenExpiredAction('auth.messages.expired'));
|
||||||
|
Reference in New Issue
Block a user