@open-rlb/ng-app 3.1.13 → 3.1.15
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.
|
@@ -9,28 +9,29 @@ import { provideServiceWorker } from '@angular/service-worker';
|
|
|
9
9
|
import * as i1$8 from '@ngrx/effects';
|
|
10
10
|
import { createEffect, ofType, provideEffects } from '@ngrx/effects';
|
|
11
11
|
import * as i1$1 from '@ngrx/store';
|
|
12
|
-
import { createActionGroup, props, emptyProps, createFeature, createReducer, on, provideStore, provideState } from '@ngrx/store';
|
|
12
|
+
import { createActionGroup, props, emptyProps, Store, createFeature, createReducer, on, provideStore, provideState } from '@ngrx/store';
|
|
13
13
|
import * as i2$1 from '@open-rlb/ng-bootstrap';
|
|
14
14
|
import { RLB_TRANSLATION_SERVICE, RlbBootstrapModule, ModalDirective, ToastDirective, ModalRegistryOptions, ToastRegistryOptions, provideRlbBootstrap } from '@open-rlb/ng-bootstrap';
|
|
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 } from 'rxjs';
|
|
18
|
+
import { filter, switchMap, map, BehaviorSubject, of, share, lastValueFrom, from, zip, EMPTY, catchError, Observable, tap, shareReplay, distinctUntilChanged, take as take$1 } 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';
|
|
25
26
|
import * as i1$6 from '@angular/common';
|
|
26
27
|
import { isPlatformServer, CommonModule } from '@angular/common';
|
|
27
28
|
import * as i3 from '@angular/forms';
|
|
28
29
|
import { FormGroup, FormControl, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
29
30
|
import * as i1$7 from '@angular/cdk/layout';
|
|
30
31
|
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
|
-
const RLB_CFG = 'rlb.options';
|
|
33
|
+
// export const RLB_CFG = 'rlb.options';
|
|
34
|
+
const RLB_CFG = new InjectionToken('rlb.options');
|
|
34
35
|
const RLB_CFG_CMS = new InjectionToken(`${RLB_CFG}:cms`);
|
|
35
36
|
const RLB_CFG_I18N = new InjectionToken(`${RLB_CFG}:i18n`);
|
|
36
37
|
const RLB_CFG_PAGES = new InjectionToken(`${RLB_CFG}:pages`);
|
|
@@ -1620,6 +1621,40 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.4", ngImpor
|
|
|
1620
1621
|
args: [RLB_CFG]
|
|
1621
1622
|
}] }] });
|
|
1622
1623
|
|
|
1624
|
+
class CompanyInterceptor {
|
|
1625
|
+
constructor() {
|
|
1626
|
+
this.store = inject(Store);
|
|
1627
|
+
this.config = inject(RLB_CFG);
|
|
1628
|
+
}
|
|
1629
|
+
intercept(req, next) {
|
|
1630
|
+
const authConfig = this.config.auth;
|
|
1631
|
+
const isAllowed = authConfig?.allowedUrls?.some(url => req.url.includes(url));
|
|
1632
|
+
if (!isAllowed || !authConfig?.enableCompanyInterceptor) {
|
|
1633
|
+
return next.handle(req);
|
|
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 });
|
|
1646
|
+
}
|
|
1647
|
+
// If no companyId and productId presented call as is
|
|
1648
|
+
return req;
|
|
1649
|
+
}), switchMap$1(clonedReq => next.handle(clonedReq)));
|
|
1650
|
+
}
|
|
1651
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.4", ngImport: i0, type: CompanyInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1652
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.4", ngImport: i0, type: CompanyInterceptor }); }
|
|
1653
|
+
}
|
|
1654
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.4", ngImport: i0, type: CompanyInterceptor, decorators: [{
|
|
1655
|
+
type: Injectable
|
|
1656
|
+
}] });
|
|
1657
|
+
|
|
1623
1658
|
function provideRlbCodeBrowserOAuth(auth) {
|
|
1624
1659
|
if (!auth || auth.protocol !== 'oauth')
|
|
1625
1660
|
return makeEnvironmentProviders([]);
|
|
@@ -1647,6 +1682,9 @@ function provideRlbCodeBrowserOAuth(auth) {
|
|
|
1647
1682
|
if (auth.interceptor === 'oauth-code-ep') {
|
|
1648
1683
|
providers.push({ provide: HTTP_INTERCEPTORS, useClass: TokenOauthInterceptor, multi: true });
|
|
1649
1684
|
}
|
|
1685
|
+
if (auth.enableCompanyInterceptor) {
|
|
1686
|
+
providers.push({ provide: HTTP_INTERCEPTORS, useClass: CompanyInterceptor, multi: true });
|
|
1687
|
+
}
|
|
1650
1688
|
if (auth.storage === 'cookies') {
|
|
1651
1689
|
providers.push({ provide: AbstractSecurityStorage, useClass: TokenCookiesService });
|
|
1652
1690
|
}
|
|
@@ -2513,7 +2551,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.4", ngImpor
|
|
|
2513
2551
|
|
|
2514
2552
|
const oauthGuard = (route, state) => {
|
|
2515
2553
|
const authService = inject(AuthenticationService);
|
|
2516
|
-
return authService.isAuthenticated$.pipe(take(1), map((isAuthenticated) => {
|
|
2554
|
+
return authService.isAuthenticated$.pipe(take$1(1), map((isAuthenticated) => {
|
|
2517
2555
|
if (!isAuthenticated) {
|
|
2518
2556
|
authService.login(state.url);
|
|
2519
2557
|
return false;
|
|
@@ -2528,7 +2566,7 @@ const permissionGuard = (route) => {
|
|
|
2528
2566
|
const resource = route.data['resource'];
|
|
2529
2567
|
const action = route.data['action'];
|
|
2530
2568
|
// toObservable helps wait for 'loaded' to be true
|
|
2531
|
-
return toObservable(store.loaded).pipe(filter(Boolean), take(1), map(() => store.hasPermission(resource, action)
|
|
2569
|
+
return toObservable(store.loaded).pipe(filter(Boolean), take$1(1), map(() => store.hasPermission(resource, action)
|
|
2532
2570
|
? true
|
|
2533
2571
|
: router.createUrlTree(['/notFound'])));
|
|
2534
2572
|
};
|