private redirectIfNotLoggedIn(observable: Observable<Response>): Observable<Response> {
   return observable.catch((err, source) => {
     if (err.status === 401) {
       this.router.navigate(['authentication', 'login']);
     }
     return Observable.throw(err);
   });
 }
  intercept(observable: Observable<Response>): Observable<Response> {
    return observable.catch((err, source) => {
      if (err.status === 401 && !err.url.endsWith('/api/authentication')) {
        //this.store.dispatch(AuthActions.loginFailed(null));
        return Observable.empty();
      } else {
        return Observable.throw(err);
      }
    });

  }
 intercept(observable: Observable<Response>): Observable<Response> {
   return observable.catch((err, source) => {
     if (err.status === 401 || err.status === 403
       || err.status === 419 || err.status === 440) {
       this._authService.triggerAuth();
       return Observable.empty();
     } else {
       return Observable.throw(err);
     }
   });
 }
 intercept(observable: Observable<Response>): Observable<Response> {
   return observable.catch((err, source) => {
     if (err.status === 401 && typeof err.url !== 'undefined' &&
         !err.url.endsWith('api/authentication')) {
       this.router.navigate(['/login']);
       return Observable.empty();
     } else {
       return Observable.throw(err);
     }
   });
 }
 public process(req:Request, observable:Observable<any>):Observable<any> {
     return observable.catch((err, source) => {
         switch (err.status) {
             case ErrorStatus.Unauthorized:
                 return this.process401();
             case ErrorStatus.Forbidden:
                 return this.process403(err);
             default:
                 return this.processXXX(err, req);
         }
     });
 }
    intercept(observable: Observable<Response>): Observable<Response> {

         return observable.catch((err, source) => {
         if (err.status  === 401) {
                console.error("401 error");
                // this.navigator.navigateToLogin({ redirectPath: "sections" });
                return Observable.empty();
            } else {
                return Observable.throw(err);
            }
        });
    }
    intercept(observable: Observable<Response>): Observable<Response> {
        console.log("inside intercept");
        return observable.catch((err, source) => {
            if (err.status  == 401 /*&& !_.endsWith(err.url, 'api/auth/login')*/) {
                this._router.navigate(['/login']);
                return Observable.empty();
            } else {
                return Observable.throw(err);
            }
        });

    }
Example #8
0
  intercept(observable: Observable<Response>): Observable<Response> {
    console.log('Intercept1=====');
    return observable.catch((err, source) => {
      if (err.status === 401 && !_.endsWith(err.url, 'authenticate')) {
        this._router.go('/login');
        return Observable.empty();
      } else {
        return Observable.throw(err);
      }
    });

  }
  private intercept(observable: Observable<Response>): Observable<Response> {
      console.log("Intercept Http Request");
      return observable.catch(res => {
        if(res.status === 401){
          let router: Router;
          router = this.injector.get(Router);
          router.navigate(['/signin']);
          return Observable.empty();
        } else {
          return Observable.throw(res);
        }
      });

    }
Example #10
0
	wrap(observable: Observable<Response>, mode: ('json' | 'text' | 'response') = 'json'): Observable<any> {
		return observable
			.catch(this.errorHandler.bind(this))
			.map( (response: Response) => {
				switch (mode) {
					case 'json':
						if(response.text().length) {
							return response.json();
						} else {
							return {};
						}
					case 'text':
						return response.text();
					default:
						return response;
				}
			});
	}
Example #11
0
    // INFO: Im really not sure about this, I dont like the fact it tries to move the user to a
    // defined place in router in this class hurting the possible portability of the class
    private _intercept(observable: Observable<Response>): Observable<Response> {
        return observable.catch((err, source) => {
            if (err.status == 401) {
                this._router.navigate(['/Home']);

                // FIXME:
                // We should really use the refresh token and get another token
                // due to deadline, had to do this blund hack, will come back to this

                this.localStorage.remove("auth_token");
                window.location.reload();

                return Observable.empty();
            } else {
                return Observable.throw(err);
            }
        });
    }