Skip to content

Commit

Permalink
refactor(auth): friendly processing logical
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Jan 11, 2018
1 parent 1062975 commit 2798610
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/core/auth/token/jwt/jwt.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 <any>ErrorObservable.create({ status: 401, _from: 'jwt_intercept' });
return of(<any>{ status: 401, _from: 'jwt_intercept' });
}
}
return next.handle(req);
Expand Down
4 changes: 2 additions & 2 deletions src/core/auth/token/simple/simple.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 <any>ErrorObservable.create({ status: 401, _from: 'simple_intercept' });
return of(<any>{ status: 401, _from: 'simple_intercept' });
}
}
return next.handle(req);
Expand Down

0 comments on commit 2798610

Please sign in to comment.