This commit is contained in:
parent
a33c7056d2
commit
569753c030
|
@ -2,12 +2,12 @@ import {Injectable} from '@angular/core';
|
||||||
import {Observable} from 'rxjs/Observable';
|
import {Observable} from 'rxjs/Observable';
|
||||||
import {HttpEvent, HttpInterceptor, HttpHandler, HttpRequest, HttpResponse, HttpErrorResponse} from '@angular/common/http';
|
import {HttpEvent, HttpInterceptor, HttpHandler, HttpRequest, HttpResponse, HttpErrorResponse} from '@angular/common/http';
|
||||||
import { TokenService, TokenProvider } from './login/token.service';
|
import { TokenService, TokenProvider } from './login/token.service';
|
||||||
|
import {Router} from '@angular/router';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class GlobalInterceptor implements HttpInterceptor {
|
export class GlobalInterceptor implements HttpInterceptor {
|
||||||
|
|
||||||
constructor(public tokenService: TokenService) {}
|
constructor(public tokenService: TokenService, private router : Router) {}
|
||||||
|
|
||||||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ export class GlobalInterceptor implements HttpInterceptor {
|
||||||
if (err instanceof HttpErrorResponse) {
|
if (err instanceof HttpErrorResponse) {
|
||||||
if (err.status === 401) {
|
if (err.status === 401) {
|
||||||
this.tokenService.logout();
|
this.tokenService.logout();
|
||||||
|
this.router.navigate(['/dmps'], { queryParams: { /*returnUrl: this.state.url*/ }});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue