|
|
|
@ -2,7 +2,13 @@ import { HttpHandler, HttpHeaders, HttpRequest } from '@angular/common/http'; |
|
|
|
import { Inject, Injectable } from '@angular/core'; |
|
|
|
import { OAuthService } from 'angular-oauth2-oidc'; |
|
|
|
import { finalize } from 'rxjs/operators'; |
|
|
|
import { SessionStateService, HttpWaitService, TENANT_KEY, IApiInterceptor } from '@abp/ng.core'; |
|
|
|
import { |
|
|
|
SessionStateService, |
|
|
|
HttpWaitService, |
|
|
|
TENANT_KEY, |
|
|
|
IApiInterceptor, |
|
|
|
IS_EXTERNAL_REQUEST, |
|
|
|
} from '@abp/ng.core'; |
|
|
|
|
|
|
|
@Injectable({ |
|
|
|
providedIn: 'root', |
|
|
|
@ -17,12 +23,15 @@ export class OAuthApiInterceptor implements IApiInterceptor { |
|
|
|
|
|
|
|
intercept(request: HttpRequest<any>, next: HttpHandler) { |
|
|
|
this.httpWaitService.addRequest(request); |
|
|
|
return next |
|
|
|
.handle( |
|
|
|
request.clone({ |
|
|
|
const isExternalRequest = request.context?.get(IS_EXTERNAL_REQUEST); |
|
|
|
const newRequest = isExternalRequest |
|
|
|
? request |
|
|
|
: request.clone({ |
|
|
|
setHeaders: this.getAdditionalHeaders(request.headers), |
|
|
|
}), |
|
|
|
) |
|
|
|
}); |
|
|
|
|
|
|
|
return next |
|
|
|
.handle(newRequest) |
|
|
|
.pipe(finalize(() => this.httpWaitService.deleteRequest(request))); |
|
|
|
} |
|
|
|
|
|
|
|
|