1 |
476b7738
|
Jakub Danek
|
import {Injectable} from '@angular/core';
|
2 |
|
|
import {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http';
|
3 |
|
|
import {Observable} from 'rxjs';
|
4 |
|
|
|
5 |
|
|
/**
|
6 |
|
|
* Adds authentication token to each request.
|
7 |
|
|
*/
|
8 |
|
|
@Injectable()
|
9 |
|
|
export class BasicAuthInterceptor implements HttpInterceptor {
|
10 |
76eb842a
|
Jakub Danek
|
constructor() {
|
11 |
476b7738
|
Jakub Danek
|
}
|
12 |
|
|
|
13 |
|
|
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
14 |
76eb842a
|
Jakub Danek
|
request = request.clone({
|
15 |
|
|
withCredentials: true,
|
16 |
|
|
});
|
17 |
476b7738
|
Jakub Danek
|
|
18 |
|
|
return next.handle(request);
|
19 |
|
|
}
|
20 |
|
|
}
|