mirror of
https://github.com/fabioformosa/quartz-manager.git
synced 2025-12-26 12:23:15 +09:00
#6 fixed authorization header set
This commit is contained in:
@@ -70,20 +70,23 @@ export class ApiService {
|
||||
}
|
||||
|
||||
private request(path: string, body: any, method = RequestMethod.Post, customHeaders?: HttpHeaders): Observable<any> {
|
||||
const req = new HttpRequest(method, path, body, {
|
||||
const options = {
|
||||
headers: customHeaders || this.headers,
|
||||
withCredentials: true
|
||||
});
|
||||
}
|
||||
|
||||
if(this.jwtToken)
|
||||
req.headers.append('Authorization', `Bearer ${this.jwtToken}`);
|
||||
options.headers = options.headers.append('Authorization', `Bearer ${this.jwtToken}`);
|
||||
|
||||
const req = new HttpRequest(method, path, body, options);
|
||||
|
||||
return this.http.request(req)
|
||||
.pipe(
|
||||
filter(response => response instanceof HttpResponse),
|
||||
tap((resp: HttpResponse<any>) => {
|
||||
let jwtToken = ApiService.extractTokenFromHttpResponse(resp);
|
||||
this.setToken(jwtToken);
|
||||
if(jwtToken)
|
||||
this.setToken(jwtToken);
|
||||
}),
|
||||
map((response: HttpResponse<any>) => response.body),
|
||||
catchError(error => this.checkError(error))
|
||||
|
||||
Reference in New Issue
Block a user