Browse Source
Merge pull request #23352 from abpframework/auto-merge/rel-9-3/3885
Merge branch dev with rel-9.3
pull/23366/head
maliming
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
12 additions and
6 deletions
-
npm/ng-packs/packages/core/src/lib/interceptors/api.interceptor.ts
-
npm/ng-packs/packages/oauth/src/lib/interceptors/api.interceptor.ts
|
|
|
@ -1,6 +1,13 @@ |
|
|
|
import { HttpHandler, HttpHeaders, HttpInterceptor, HttpRequest } from '@angular/common/http'; |
|
|
|
import { |
|
|
|
HttpHandler, |
|
|
|
HttpHeaders, |
|
|
|
HttpInterceptor, |
|
|
|
HttpRequest, |
|
|
|
HttpEvent, |
|
|
|
} from '@angular/common/http'; |
|
|
|
import { Injectable, inject } from '@angular/core'; |
|
|
|
import { finalize } from 'rxjs/operators'; |
|
|
|
import { Observable } from 'rxjs'; |
|
|
|
import { HttpWaitService } from '../services'; |
|
|
|
|
|
|
|
@Injectable({ |
|
|
|
@ -9,12 +16,11 @@ import { HttpWaitService } from '../services'; |
|
|
|
export class ApiInterceptor implements IApiInterceptor { |
|
|
|
private httpWaitService = inject(HttpWaitService); |
|
|
|
|
|
|
|
|
|
|
|
getAdditionalHeaders(existingHeaders?: HttpHeaders) { |
|
|
|
return existingHeaders || new HttpHeaders(); |
|
|
|
} |
|
|
|
|
|
|
|
intercept(request: HttpRequest<any>, next: HttpHandler) { |
|
|
|
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { |
|
|
|
this.httpWaitService.addRequest(request); |
|
|
|
return next.handle(request).pipe(finalize(() => this.httpWaitService.deleteRequest(request))); |
|
|
|
} |
|
|
|
|
|
|
|
@ -1,7 +1,8 @@ |
|
|
|
import { HttpHandler, HttpHeaders, HttpRequest } from '@angular/common/http'; |
|
|
|
import { HttpEvent, HttpHandler, HttpHeaders, HttpRequest } from '@angular/common/http'; |
|
|
|
import { Injectable, inject } from '@angular/core'; |
|
|
|
import { OAuthService } from 'angular-oauth2-oidc'; |
|
|
|
import { finalize } from 'rxjs/operators'; |
|
|
|
import { Observable } from 'rxjs'; |
|
|
|
import { |
|
|
|
HttpWaitService, |
|
|
|
IApiInterceptor, |
|
|
|
@ -19,8 +20,7 @@ export class OAuthApiInterceptor implements IApiInterceptor { |
|
|
|
private httpWaitService = inject(HttpWaitService); |
|
|
|
private tenantKey = inject(TENANT_KEY); |
|
|
|
|
|
|
|
|
|
|
|
intercept(request: HttpRequest<any>, next: HttpHandler) { |
|
|
|
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { |
|
|
|
this.httpWaitService.addRequest(request); |
|
|
|
const isExternalRequest = request.context?.get(IS_EXTERNAL_REQUEST); |
|
|
|
const newRequest = isExternalRequest |
|
|
|
|