@open-rlb/ng-app 3.1.16 → 3.1.18

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.
@@ -15,20 +15,20 @@ import { RLB_TRANSLATION_SERVICE, RlbBootstrapModule, ModalDirective, ToastDirec
15
15
  import * as i1$5 from 'angular-auth-oidc-client';
16
16
  import { AbstractLoggerService, AuthModule, provideAuth, AuthInterceptor, AbstractSecurityStorage } from 'angular-auth-oidc-client';
17
17
  import * as i1 from 'ngx-cookie-service-ssr';
18
- import { filter, switchMap, map, BehaviorSubject, of, share, lastValueFrom, from, zip, EMPTY, catchError, Observable, tap, shareReplay, distinctUntilChanged, take as take$1 } from 'rxjs';
18
+ import { filter, switchMap, map, BehaviorSubject, of, share, lastValueFrom, from, zip, EMPTY, catchError, Observable, tap, shareReplay, distinctUntilChanged, take } from 'rxjs';
19
19
  import { signalStore, withState, withMethods, patchState } from '@ngrx/signals';
20
20
  import { tapResponse } from '@ngrx/operators';
21
21
  import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
22
22
  import * as i1$3 from '@ngx-translate/core';
23
23
  import { TranslateModule } from '@ngx-translate/core';
24
24
  import { provideTranslateHttpLoader } from '@ngx-translate/http-loader';
25
- import { take, map as map$1, switchMap as switchMap$1, tap as tap$1 } from 'rxjs/operators';
26
25
  import * as i1$6 from '@angular/common';
27
26
  import { isPlatformServer, CommonModule } from '@angular/common';
28
27
  import * as i3 from '@angular/forms';
29
28
  import { FormGroup, FormControl, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
30
29
  import * as i1$7 from '@angular/cdk/layout';
31
30
  import { Breakpoints } from '@angular/cdk/layout';
31
+ import { tap as tap$1, map as map$1, switchMap as switchMap$1 } from 'rxjs/operators';
32
32
 
33
33
  // export const RLB_CFG = 'rlb.options';
34
34
  const RLB_CFG = new InjectionToken('rlb.options');
@@ -1632,21 +1632,18 @@ class CompanyInterceptor {
1632
1632
  if (!isAllowed || !authConfig?.enableCompanyInterceptor) {
1633
1633
  return next.handle(req);
1634
1634
  }
1635
- return this.store.select(state => state[appContextFeatureKey].currentApp).pipe(take(1), map$1((app) => {
1636
- // Get the correct keys from config
1637
- const companyKey = this.config.acl?.interceptorMapping?.companyIdKey ?? 'companyId';
1638
- const productKey = this.config.acl?.interceptorMapping?.productIdKey ?? 'productId';
1639
- const companyId = app?.data?.companyId;
1640
- const productId = app?.data?.productId;
1641
- if (companyId && productId) {
1642
- const params = req.params
1643
- .set(companyKey, companyId)
1644
- .set(productKey, productId);
1645
- return req.clone({ params });
1635
+ const currentApp = this.store.selectSignal(state => state[appContextFeatureKey].currentApp)();
1636
+ const data = currentApp?.data;
1637
+ const mapping = this.config.acl?.interceptorMapping || {};
1638
+ const map = Object.keys(mapping).forEach((key) => {
1639
+ const storeKey = mapping[key];
1640
+ const value = data?.[storeKey];
1641
+ if (!!value) {
1642
+ req.params.set(key, value);
1646
1643
  }
1647
- // If no companyId and productId presented call as is
1648
- return req;
1649
- }), switchMap$1(clonedReq => next.handle(clonedReq)));
1644
+ });
1645
+ const clonedReq = req.clone({ params: req.params });
1646
+ return next.handle(clonedReq);
1650
1647
  }
1651
1648
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.4", ngImport: i0, type: CompanyInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1652
1649
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.4", ngImport: i0, type: CompanyInterceptor }); }
@@ -2551,7 +2548,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.4", ngImpor
2551
2548
 
2552
2549
  const oauthGuard = (route, state) => {
2553
2550
  const authService = inject(AuthenticationService);
2554
- return authService.isAuthenticated$.pipe(take$1(1), map((isAuthenticated) => {
2551
+ return authService.isAuthenticated$.pipe(take(1), map((isAuthenticated) => {
2555
2552
  if (!isAuthenticated) {
2556
2553
  authService.login(state.url);
2557
2554
  return false;
@@ -2566,7 +2563,7 @@ const permissionGuard = (route) => {
2566
2563
  const resource = route.data['resource'];
2567
2564
  const action = route.data['action'];
2568
2565
  // toObservable helps wait for 'loaded' to be true
2569
- return toObservable(store.loaded).pipe(filter(Boolean), take$1(1), map(() => store.hasPermission(resource, action)
2566
+ return toObservable(store.loaded).pipe(filter(Boolean), take(1), map(() => store.hasPermission(resource, action)
2570
2567
  ? true
2571
2568
  : router.createUrlTree(['/notFound'])));
2572
2569
  };