From 27986100d1594e901c084294742205d244813590 Mon Sep 17 00:00:00 2001 From: cipchk Date: Thu, 11 Jan 2018 19:19:07 +0800 Subject: [PATCH] refactor(auth): friendly processing logical --- src/core/auth/token/jwt/jwt.interceptor.ts | 4 ++-- src/core/auth/token/simple/simple.interceptor.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/auth/token/jwt/jwt.interceptor.ts b/src/core/auth/token/jwt/jwt.interceptor.ts index b8641d03af..6282166484 100644 --- a/src/core/auth/token/jwt/jwt.interceptor.ts +++ b/src/core/auth/token/jwt/jwt.interceptor.ts @@ -4,7 +4,7 @@ import { HttpInterceptor, HttpRequest, HttpHandler, HttpSentEvent, HttpHeaderResponse, HttpProgressEvent, HttpResponse, HttpUserEvent, HttpHeaders } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; -import { ErrorObservable } from 'rxjs/observable/ErrorObservable'; +import { of } from 'rxjs/observable/of'; import { ITokenModel, DA_SERVICE_TOKEN } from '../interface'; import { JWTTokenModel } from './jwt.model'; import { DA_OPTIONS_TOKEN } from '../../auth.options'; @@ -37,7 +37,7 @@ export class JWTInterceptor implements HttpInterceptor { if (options.token_invalid_redirect === true) { const router = this.injector.get(Router); this.injector.get(Router).navigate([ options.login_url ]); - return ErrorObservable.create({ status: 401, _from: 'jwt_intercept' }); + return of({ status: 401, _from: 'jwt_intercept' }); } } return next.handle(req); diff --git a/src/core/auth/token/simple/simple.interceptor.ts b/src/core/auth/token/simple/simple.interceptor.ts index 72d384c8fd..4010596fd5 100644 --- a/src/core/auth/token/simple/simple.interceptor.ts +++ b/src/core/auth/token/simple/simple.interceptor.ts @@ -4,7 +4,7 @@ import { HttpInterceptor, HttpRequest, HttpHandler, HttpSentEvent, HttpHeaderResponse, HttpProgressEvent, HttpResponse, HttpUserEvent, HttpHeaders } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; -import { ErrorObservable } from 'rxjs/observable/ErrorObservable'; +import { of } from 'rxjs/observable/of'; import { ITokenModel, DA_SERVICE_TOKEN } from '../interface'; import { DA_OPTIONS_TOKEN } from '../../auth.options'; import { SimpleTokenModel } from './simple.model'; @@ -55,7 +55,7 @@ export class SimpleInterceptor implements HttpInterceptor { } else { if (options.token_invalid_redirect === true) { this.injector.get(Router).navigate([ options.login_url ]); - return ErrorObservable.create({ status: 401, _from: 'simple_intercept' }); + return of({ status: 401, _from: 'simple_intercept' }); } } return next.handle(req);