@brggroup/share-lib 0.1.1 → 0.1.12

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.
@@ -4,7 +4,7 @@ import * as i1$4 from '@angular/router';
4
4
  import { Router, ActivatedRoute, NavigationEnd, RouterLink, RouterOutlet } from '@angular/router';
5
5
  import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
6
6
  import * as i3 from '@ngx-translate/core';
7
- import { TranslateService, TranslatePipe, TranslateModule } from '@ngx-translate/core';
7
+ import { TranslateService, TranslateModule } from '@ngx-translate/core';
8
8
  import { firstValueFrom, fromEvent, startWith, map, BehaviorSubject, of, catchError, throwError, finalize, from, switchMap as switchMap$1, take, filter, Subject, takeUntil as takeUntil$1 } from 'rxjs';
9
9
  import { NzNotificationService } from 'ng-zorro-antd/notification';
10
10
  import * as i1 from 'ng-zorro-antd/modal';
@@ -719,6 +719,16 @@ class AuthService extends HTTPService {
719
719
  let params = new HttpParams().append('App_Org_Id', App_Org_Id);
720
720
  return this.postParams(AppGlobals.apiEndpoint + URLs$4.changeOrgLogin, params);
721
721
  }
722
+ static pingInterVal;
723
+ startPingAuth(intervalTime) {
724
+ if (!AuthService.pingInterVal) {
725
+ AuthService.pingInterVal = setInterval(() => this.pingAuth(), intervalTime || 60 * 1000);
726
+ }
727
+ }
728
+ stopPingAuth() {
729
+ clearInterval(AuthService.pingInterVal);
730
+ AuthService.pingInterVal = undefined;
731
+ }
722
732
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: AuthService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
723
733
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: AuthService, providedIn: 'root' });
724
734
  }
@@ -737,6 +747,7 @@ class AuthGuard {
737
747
  if (await this.authService.pingAuth()) {
738
748
  return true;
739
749
  }
750
+ this.authService.startPingAuth();
740
751
  TokenStorage.clearToken();
741
752
  if (state.url != '/') {
742
753
  if (!state.url.startsWith('/login')) {
@@ -803,7 +814,7 @@ function authInterceptor(req, next) {
803
814
  const router = inject(Router);
804
815
  const loadingService = inject(LoadingService);
805
816
  const authService = inject(AuthService);
806
- const translate = inject(TranslatePipe);
817
+ const translate = inject(TranslateService);
807
818
  const authToken = TokenStorage.getToken();
808
819
  const noLoadingMark = req.headers.get('No-Loading-Mark');
809
820
  if (noLoadingMark !== '1')
@@ -849,8 +860,8 @@ function handle401(req, next, router, authService, translate) {
849
860
  router.navigate(['/login'], {
850
861
  queryParams: { returnUrl: initialReturnUrl || '/' },
851
862
  });
852
- refreshTokenSubject.error(translate.transform('Refresh token failed'));
853
- return throwError(() => new Error(translate.transform('Refresh token failed')));
863
+ refreshTokenSubject.error(translate.instant('Refresh token failed'));
864
+ return throwError(() => new Error(translate.instant('Refresh token failed')));
854
865
  }
855
866
  // Phát token mới cho các request đang chờ
856
867
  refreshTokenSubject.next(TokenStorage.getToken());
@@ -7092,6 +7103,7 @@ class LoginComponent extends BaseComponent {
7092
7103
  isOneUserMultiOrgs = false;
7093
7104
  SYSTEM_NAME_LOGIN = '';
7094
7105
  async ngOnInit() {
7106
+ this.authService.stopPingAuth();
7095
7107
  this.route.queryParams.subscribe((params) => (this.returnUrl = params['returnUrl'] || '/'));
7096
7108
  if (TokenStorage.getToken() && (await this.authService.pingAuth())) {
7097
7109
  this.goto(this.returnUrl);