@brggroup/share-lib 0.0.35 → 0.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,7 +5,7 @@ import { Router, ActivatedRoute, NavigationEnd } from '@angular/router';
|
|
|
5
5
|
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
|
6
6
|
import * as i3 from '@ngx-translate/core';
|
|
7
7
|
import { TranslateService, TranslateModule } from '@ngx-translate/core';
|
|
8
|
-
import { firstValueFrom, BehaviorSubject, of, catchError, throwError, finalize, from, switchMap as switchMap$1,
|
|
8
|
+
import { firstValueFrom, BehaviorSubject, of, catchError, throwError, finalize, from, switchMap as switchMap$1, take, filter, fromEvent } from 'rxjs';
|
|
9
9
|
import { NzNotificationService } from 'ng-zorro-antd/notification';
|
|
10
10
|
import * as i1 from 'ng-zorro-antd/modal';
|
|
11
11
|
import { NzModalService } from 'ng-zorro-antd/modal';
|
|
@@ -756,10 +756,8 @@ function handle401(req, next, router, authService) {
|
|
|
756
756
|
router.navigate(['/login'], {
|
|
757
757
|
queryParams: { returnUrl: initialReturnUrl || '/' },
|
|
758
758
|
});
|
|
759
|
-
refreshTokenSubject.
|
|
760
|
-
return
|
|
761
|
-
IsSuccess: false,
|
|
762
|
-
});
|
|
759
|
+
refreshTokenSubject.error('Refresh token failed');
|
|
760
|
+
return throwError(() => new Error('Refresh token failed'));
|
|
763
761
|
}
|
|
764
762
|
// Phát token mới cho các request đang chờ
|
|
765
763
|
refreshTokenSubject.next(TokenStorage.getToken());
|
|
@@ -782,9 +780,9 @@ function handle401(req, next, router, authService) {
|
|
|
782
780
|
}
|
|
783
781
|
else {
|
|
784
782
|
// Nếu đang refresh → chờ token mới rồi retry
|
|
785
|
-
return refreshTokenSubject.pipe(
|
|
783
|
+
return refreshTokenSubject.pipe(take(1), switchMap$1((token) => next(req.clone({
|
|
786
784
|
setHeaders: { Authorization: `Bearer ${token}` },
|
|
787
|
-
}))));
|
|
785
|
+
}))), catchError((err) => throwError(() => err)));
|
|
788
786
|
}
|
|
789
787
|
}
|
|
790
788
|
function convertDatesInBody(obj) {
|