import { Injectable } from '@angular/core' ; import { HttpRequest , HttpHandler , HttpEvent , HttpInterceptor } from '@angular/common/http' ; import { Observable } from 'rxjs' ; import { AuthenticationService } from '@app/_services' ; @ Injectable ( ) export class BasicAuthInterceptor implements HttpInterceptor { constructor ( private authenticationService ) { } intercept ( request , next ) { const currentUser = this . authenticationService . currentUserValue ; if ( currentUser && currentUser . authdata ) { request = request . clone ( { setHeaders : { Authorization : `Basic ${ currentUser . authdata }` } } ) ; } return next . handle ( request ) ; } }