@posiwise/common-services 0.1.53 → 0.1.55
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.
- package/esm2022/lib/ab-test.service.mjs +1 -1
- package/esm2022/lib/ahoy.service.mjs +2 -2
- package/esm2022/lib/auth.service.mjs +5 -5
- package/esm2022/lib/base-http.service.mjs +1 -1
- package/esm2022/lib/common-services.interface.mjs +1 -1
- package/esm2022/lib/common-services.module.mjs +5 -5
- package/esm2022/lib/common.service.mjs +2 -2
- package/esm2022/lib/custom-preloading.service.mjs +1 -1
- package/esm2022/lib/data.service.mjs +1 -1
- package/esm2022/lib/date-formatter.service.mjs +2 -2
- package/esm2022/lib/effects/user.effects.mjs +2 -2
- package/esm2022/lib/geo.service.mjs +2 -2
- package/esm2022/lib/google-analytics.service.mjs +1 -1
- package/esm2022/lib/group.service.mjs +2 -2
- package/esm2022/lib/hopscotch.service.mjs +1 -1
- package/esm2022/lib/integrations-api-http.service.mjs +3 -3
- package/esm2022/lib/local-storage.service.mjs +1 -1
- package/esm2022/lib/mailbox.service.mjs +1 -1
- package/esm2022/lib/main-api-http.service.mjs +3 -3
- package/esm2022/lib/notification.service.mjs +3 -3
- package/esm2022/lib/permission.service.mjs +54 -41
- package/esm2022/lib/product.service.mjs +1 -1
- package/esm2022/lib/profile.service.mjs +1 -1
- package/esm2022/lib/qualification.service.mjs +1 -1
- package/esm2022/lib/sentry.service.mjs +3 -3
- package/esm2022/lib/socket.service.mjs +2 -2
- package/esm2022/lib/subscription.service.mjs +1 -1
- package/esm2022/lib/tag.service.mjs +1 -1
- package/esm2022/lib/tips.service.mjs +1 -1
- package/esm2022/lib/toast.service.mjs +2 -2
- package/esm2022/lib/user.service.mjs +4 -4
- package/fesm2022/posiwise-common-services.mjs +132 -119
- package/fesm2022/posiwise-common-services.mjs.map +1 -1
- package/lib/ahoy.service.d.ts +1 -1
- package/lib/auth.service.d.ts +3 -3
- package/lib/common.service.d.ts +1 -1
- package/lib/effects/user.effects.d.ts +1 -1
- package/lib/group.service.d.ts +1 -1
- package/lib/integrations-api-http.service.d.ts +1 -1
- package/lib/main-api-http.service.d.ts +1 -1
- package/lib/notification.service.d.ts +1 -1
- package/lib/permission.service.d.ts +1 -0
- package/lib/profile.service.d.ts +1 -1
- package/lib/sentry.service.d.ts +1 -1
- package/lib/socket.service.d.ts +1 -1
- package/lib/user.service.d.ts +2 -2
- package/package.json +1 -1
|
@@ -7,28 +7,28 @@ import { AppConfigService } from '@posiwise/app-config-service';
|
|
|
7
7
|
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
8
8
|
import * as i1$3 from '@angular/common/http';
|
|
9
9
|
import { HttpErrorResponse, HttpHeaders } from '@angular/common/http';
|
|
10
|
-
import { throwError,
|
|
11
|
-
import { catchError,
|
|
12
|
-
import * as i1$2 from 'ngx-toastr';
|
|
10
|
+
import { throwError, of, tap, BehaviorSubject, timer } from 'rxjs';
|
|
11
|
+
import { catchError, switchMap, map, mergeMap, tap as tap$1, distinctUntilChanged } from 'rxjs/operators';
|
|
13
12
|
import { HelperService } from '@posiwise/helper-service';
|
|
13
|
+
import * as i1$2 from 'ngx-toastr';
|
|
14
|
+
import { getUser, UserActionTypes, SetUser, appReducers } from '@posiwise/app-store';
|
|
14
15
|
import * as i1$4 from '@ngrx/effects';
|
|
15
16
|
import { Actions, createEffect, ofType, EffectsModule } from '@ngrx/effects';
|
|
16
|
-
import { getUser, UserActionTypes, SetUser, appReducers } from '@posiwise/app-store';
|
|
17
17
|
import * as i2 from '@ngrx/store';
|
|
18
18
|
import { StoreModule } from '@ngrx/store';
|
|
19
|
-
import { MAIN_API_PREFIX, USER_PATH,
|
|
19
|
+
import { INTEGRATIONS_API_PREFIX, MAIN_API_PREFIX, USER_PATH, USER_IMPERSONATED_TOKEN, USER_IMPERSONATED_PHONEGAP_TOKEN, TOKEN_KEY, TOKEN_HEADER_KEY, NEWSLETTER_CONFIRMATION_PATH, NEWSLETTER_UNSUBSCRIBE_PATH, CAPTCHA_VALIDATION_PATH, SOCIAL_LOGIN_PATH, PERMISSION_NAMES, ADMIN_SUB_MENU_WHITELIST, AB_TEST_ACTIONS, GEO_PATH, PROJECT_PATH, PRODUCT_PATH, CONTACT_US_PATH, INCIDENTS_PATH, INCIDENTS_PATH_ADMIN, NEWSLETTERS_PATH, NEWSLETTER_SUBSCRIPTION_PATH, ADMIN_FAQS_PATH, FAQS_PATH, ORGANIZATIONS_PATH, GLOBAL_SUBSCRIPTION_CONFIGS_PATH, GLOBAL_CONFIGS_PATH, USER_LOGIN_NOTIFICATION, FEEDBACK_QUESTIONS_PATH, USER_FEEDBACKS_PATH, CUSTOMER_SUPPORT_PATH, ADMIN_TAG_PATH, ADMIN_TAG_CATEGORIES_PATH, ADMIN_PATH, QUALIFICATIONS_PATH, SOCKET_TYPE } from '@posiwise/common-utilities';
|
|
20
20
|
import swal from 'sweetalert2';
|
|
21
21
|
import cloneDeep from 'lodash/cloneDeep';
|
|
22
22
|
import pickBy from 'lodash/pickBy';
|
|
23
23
|
import * as i2$1 from 'ngx-cookie';
|
|
24
24
|
import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
|
|
25
|
-
import { NgbDateParserFormatter } from '@ng-bootstrap/ng-bootstrap';
|
|
26
25
|
import isNumber from 'lodash/isNumber';
|
|
27
26
|
import moment from 'moment';
|
|
27
|
+
import { NgbDateParserFormatter } from '@ng-bootstrap/ng-bootstrap';
|
|
28
28
|
import { webSocket } from 'rxjs/webSocket';
|
|
29
|
-
import * as Sentry from '@sentry/angular-ivy';
|
|
30
29
|
import { StatusCodes } from 'http-status-codes';
|
|
31
30
|
import { fromError } from 'stacktrace-js';
|
|
31
|
+
import * as Sentry from '@sentry/angular-ivy';
|
|
32
32
|
|
|
33
33
|
class ScriptLoaderService {
|
|
34
34
|
constructor(document) {
|
|
@@ -384,6 +384,56 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImpo
|
|
|
384
384
|
type: Injectable
|
|
385
385
|
}], ctorParameters: () => [{ type: i1$3.HttpClient }, { type: i0.Injector }] });
|
|
386
386
|
|
|
387
|
+
class IntegrationsApiHttpService extends BaseHttpService {
|
|
388
|
+
constructor(http, injector) {
|
|
389
|
+
super(http, injector);
|
|
390
|
+
}
|
|
391
|
+
getConfig() {
|
|
392
|
+
this.injector.get(AppConfigService).appConfig$.subscribe(config => {
|
|
393
|
+
this.baseUrl = isDevMode()
|
|
394
|
+
? INTEGRATIONS_API_PREFIX
|
|
395
|
+
: config?.['links']?.integrations_api;
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: IntegrationsApiHttpService, deps: [{ token: i1$3.HttpClient }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
399
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: IntegrationsApiHttpService, providedIn: 'root' }); }
|
|
400
|
+
}
|
|
401
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: IntegrationsApiHttpService, decorators: [{
|
|
402
|
+
type: Injectable,
|
|
403
|
+
args: [{
|
|
404
|
+
providedIn: 'root'
|
|
405
|
+
}]
|
|
406
|
+
}], ctorParameters: () => [{ type: i1$3.HttpClient }, { type: i0.Injector }] });
|
|
407
|
+
|
|
408
|
+
class LocalStorage {
|
|
409
|
+
getItem$(key) {
|
|
410
|
+
return of(localStorage.getItem(key));
|
|
411
|
+
}
|
|
412
|
+
setItem$(key, value) {
|
|
413
|
+
return of(localStorage.setItem(key, value));
|
|
414
|
+
}
|
|
415
|
+
removeItem$(key) {
|
|
416
|
+
return of(localStorage.removeItem(key));
|
|
417
|
+
}
|
|
418
|
+
clear$() {
|
|
419
|
+
return of(localStorage.clear());
|
|
420
|
+
}
|
|
421
|
+
clearAll() {
|
|
422
|
+
return localStorage.clear();
|
|
423
|
+
}
|
|
424
|
+
getItem(key) {
|
|
425
|
+
return localStorage.getItem(key);
|
|
426
|
+
}
|
|
427
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: LocalStorage, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
428
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: LocalStorage, providedIn: 'root' }); }
|
|
429
|
+
}
|
|
430
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: LocalStorage, decorators: [{
|
|
431
|
+
type: Injectable,
|
|
432
|
+
args: [{
|
|
433
|
+
providedIn: 'root'
|
|
434
|
+
}]
|
|
435
|
+
}] });
|
|
436
|
+
|
|
387
437
|
class MainApiHttpService extends BaseHttpService {
|
|
388
438
|
constructor(http, injector) {
|
|
389
439
|
super(http, injector);
|
|
@@ -500,76 +550,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImpo
|
|
|
500
550
|
}]
|
|
501
551
|
}], ctorParameters: () => [{ type: MainApiHttpService }, { type: i2.Store }, { type: i1.Router }] });
|
|
502
552
|
|
|
503
|
-
/* NgRx */
|
|
504
|
-
class UserEffects {
|
|
505
|
-
constructor(userService) {
|
|
506
|
-
this.userService = userService;
|
|
507
|
-
this.actions$ = inject(Actions);
|
|
508
|
-
this.loadUser$ = createEffect(() => {
|
|
509
|
-
return this.actions$.pipe(ofType(UserActionTypes.GET_USER),
|
|
510
|
-
// take(1),
|
|
511
|
-
mergeMap(() => this.userService.getUserInfo().pipe(map(response => new SetUser(response))
|
|
512
|
-
// catchError(err => of(new userActions.LoadFail(err)))
|
|
513
|
-
)));
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: UserEffects, deps: [{ token: UserService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
517
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: UserEffects }); }
|
|
518
|
-
}
|
|
519
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: UserEffects, decorators: [{
|
|
520
|
-
type: Injectable
|
|
521
|
-
}], ctorParameters: () => [{ type: UserService }] });
|
|
522
|
-
|
|
523
|
-
class LocalStorage {
|
|
524
|
-
getItem$(key) {
|
|
525
|
-
return of(localStorage.getItem(key));
|
|
526
|
-
}
|
|
527
|
-
setItem$(key, value) {
|
|
528
|
-
return of(localStorage.setItem(key, value));
|
|
529
|
-
}
|
|
530
|
-
removeItem$(key) {
|
|
531
|
-
return of(localStorage.removeItem(key));
|
|
532
|
-
}
|
|
533
|
-
clear$() {
|
|
534
|
-
return of(localStorage.clear());
|
|
535
|
-
}
|
|
536
|
-
clearAll() {
|
|
537
|
-
return localStorage.clear();
|
|
538
|
-
}
|
|
539
|
-
getItem(key) {
|
|
540
|
-
return localStorage.getItem(key);
|
|
541
|
-
}
|
|
542
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: LocalStorage, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
543
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: LocalStorage, providedIn: 'root' }); }
|
|
544
|
-
}
|
|
545
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: LocalStorage, decorators: [{
|
|
546
|
-
type: Injectable,
|
|
547
|
-
args: [{
|
|
548
|
-
providedIn: 'root'
|
|
549
|
-
}]
|
|
550
|
-
}] });
|
|
551
|
-
|
|
552
|
-
class IntegrationsApiHttpService extends BaseHttpService {
|
|
553
|
-
constructor(http, injector) {
|
|
554
|
-
super(http, injector);
|
|
555
|
-
}
|
|
556
|
-
getConfig() {
|
|
557
|
-
this.injector.get(AppConfigService).appConfig$.subscribe(config => {
|
|
558
|
-
this.baseUrl = isDevMode()
|
|
559
|
-
? INTEGRATIONS_API_PREFIX
|
|
560
|
-
: config?.['links']?.integrations_api;
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: IntegrationsApiHttpService, deps: [{ token: i1$3.HttpClient }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
564
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: IntegrationsApiHttpService, providedIn: 'root' }); }
|
|
565
|
-
}
|
|
566
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: IntegrationsApiHttpService, decorators: [{
|
|
567
|
-
type: Injectable,
|
|
568
|
-
args: [{
|
|
569
|
-
providedIn: 'root'
|
|
570
|
-
}]
|
|
571
|
-
}], ctorParameters: () => [{ type: i1$3.HttpClient }, { type: i0.Injector }] });
|
|
572
|
-
|
|
573
553
|
class AuthService {
|
|
574
554
|
constructor(localStorage, router, http, userService, toastr, appConfigService, integrationsApi, document) {
|
|
575
555
|
this.localStorage = localStorage;
|
|
@@ -581,10 +561,10 @@ class AuthService {
|
|
|
581
561
|
this.integrationsApi = integrationsApi;
|
|
582
562
|
this.document = document;
|
|
583
563
|
this.platformSubject = new BehaviorSubject('');
|
|
584
|
-
this.platform$ = this.platformSubject.asObservable();
|
|
585
564
|
this.twitterEndpoint = '/twitter';
|
|
586
565
|
this.header_key = 'browser';
|
|
587
566
|
this.platform = '';
|
|
567
|
+
this.platform$ = this.platformSubject.asObservable();
|
|
588
568
|
// Set Header Key
|
|
589
569
|
this.setHeaderKey();
|
|
590
570
|
}
|
|
@@ -847,6 +827,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImpo
|
|
|
847
827
|
args: [DOCUMENT]
|
|
848
828
|
}] }] });
|
|
849
829
|
|
|
830
|
+
/* NgRx */
|
|
831
|
+
class UserEffects {
|
|
832
|
+
constructor(userService) {
|
|
833
|
+
this.userService = userService;
|
|
834
|
+
this.actions$ = inject(Actions);
|
|
835
|
+
this.loadUser$ = createEffect(() => {
|
|
836
|
+
return this.actions$.pipe(ofType(UserActionTypes.GET_USER),
|
|
837
|
+
// take(1),
|
|
838
|
+
mergeMap(() => this.userService.getUserInfo().pipe(map(response => new SetUser(response))
|
|
839
|
+
// catchError(err => of(new userActions.LoadFail(err)))
|
|
840
|
+
)));
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: UserEffects, deps: [{ token: UserService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
844
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: UserEffects }); }
|
|
845
|
+
}
|
|
846
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: UserEffects, decorators: [{
|
|
847
|
+
type: Injectable
|
|
848
|
+
}], ctorParameters: () => [{ type: UserService }] });
|
|
849
|
+
|
|
850
850
|
class CommonServicesModule {
|
|
851
851
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: CommonServicesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
852
852
|
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.11", ngImport: i0, type: CommonServicesModule, imports: [CommonModule, i1$4.EffectsRootModule, i2.StoreRootModule] }); }
|
|
@@ -882,41 +882,60 @@ class PermissionService {
|
|
|
882
882
|
// Returning true if user has a given permission
|
|
883
883
|
// E.g., Pages.Role.CloudOlive.SalesManager
|
|
884
884
|
// or Pages.Beta or Pages.Alpha
|
|
885
|
-
|
|
886
|
-
return true;
|
|
887
|
-
}
|
|
888
|
-
if (productKey) {
|
|
889
|
-
// filters the permission only for the selected product.
|
|
890
|
-
let filteredPermissions = pickBy(cloneDeep(user['auth']['granted']), (_value, key) => {
|
|
891
|
-
return key.includes(productKey);
|
|
892
|
-
});
|
|
893
|
-
// add Pages.Product.{permission_key}
|
|
894
|
-
filteredPermissions = {
|
|
895
|
-
...{ [`Pages.Product.${permission_key}`]: true },
|
|
896
|
-
...filteredPermissions
|
|
897
|
-
};
|
|
898
|
-
// E.g., Pages.Product.CloudOlive.CloudOlive_MspKey
|
|
899
|
-
return filteredPermissions[permissionName] || false;
|
|
900
|
-
}
|
|
885
|
+
return this.hasProductPermission(user, permissionName, productKey, permission_key);
|
|
901
886
|
// no valid permission was detected for this user
|
|
902
|
-
return false;
|
|
903
887
|
}
|
|
904
888
|
// user not logged-in
|
|
905
889
|
return false;
|
|
906
890
|
}
|
|
891
|
+
hasProductPermission(user, permissionName, productKey, permission_key) {
|
|
892
|
+
if (permissionName?.includes('||')) {
|
|
893
|
+
const parts = permissionName.split('||').map(p => p.trim());
|
|
894
|
+
for (const part of parts) {
|
|
895
|
+
if (user['auth']?.['granted'][part]) {
|
|
896
|
+
return true;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
else if (user['auth']?.['granted'][permissionName]) {
|
|
901
|
+
return true;
|
|
902
|
+
}
|
|
903
|
+
if (productKey) {
|
|
904
|
+
// filters the permission only for the selected product.
|
|
905
|
+
let filteredPermissions = pickBy(cloneDeep(user['auth']['granted']), (_value, key) => {
|
|
906
|
+
return key.includes(productKey);
|
|
907
|
+
});
|
|
908
|
+
// add Pages.Product.{permission_key}
|
|
909
|
+
filteredPermissions = {
|
|
910
|
+
...{ [`Pages.Product.${permission_key}`]: true },
|
|
911
|
+
...filteredPermissions
|
|
912
|
+
};
|
|
913
|
+
// E.g., Pages.Product.CloudOlive.CloudOlive_MspKey
|
|
914
|
+
return filteredPermissions[permissionName] || false;
|
|
915
|
+
}
|
|
916
|
+
return false;
|
|
917
|
+
}
|
|
907
918
|
getFormattedPermissionName(permissionName, productSlug) {
|
|
908
919
|
const selectedProduct = PermissionService?.selectedProduct || this.getCurrentProduct();
|
|
909
920
|
const subscriptionSlug = selectedProduct?.subscription_slug;
|
|
910
921
|
let slugToCheck;
|
|
911
922
|
if (!productSlug) {
|
|
912
|
-
|
|
923
|
+
if (permissionName.includes('Pages.Product.')) {
|
|
924
|
+
slugToCheck = `Pages.Product.${subscriptionSlug}.`;
|
|
925
|
+
}
|
|
926
|
+
if (permissionName.includes('Pages.Role.')) {
|
|
927
|
+
slugToCheck = `Pages.Role.${subscriptionSlug}.`;
|
|
928
|
+
}
|
|
913
929
|
}
|
|
914
930
|
else {
|
|
915
931
|
slugToCheck = productSlug;
|
|
916
932
|
}
|
|
917
|
-
if (!permissionName.includes(slugToCheck)) {
|
|
933
|
+
if (!permissionName.includes(slugToCheck) && permissionName.includes('Pages.Product.')) {
|
|
918
934
|
permissionName = permissionName.replace('Pages.Product.', slugToCheck);
|
|
919
935
|
}
|
|
936
|
+
if (permissionName.includes('Pages.Role.') && !permissionName.includes(slugToCheck)) {
|
|
937
|
+
permissionName = permissionName.replace('Pages.Role.', slugToCheck);
|
|
938
|
+
}
|
|
920
939
|
return permissionName;
|
|
921
940
|
}
|
|
922
941
|
getPermissionTreeDataByRole(data) {
|
|
@@ -939,7 +958,6 @@ class PermissionService {
|
|
|
939
958
|
if (!permission) {
|
|
940
959
|
return false;
|
|
941
960
|
}
|
|
942
|
-
console.log(permission, productKey, permission_key, productSlug);
|
|
943
961
|
// - `SuperAdmin` => God-like power - Most privileged
|
|
944
962
|
// - `SubscriptionSuperOwner` => Some of the features under Admin Menu
|
|
945
963
|
// - `SubscriptionSuperAdmin` => Some of the features under Admin Menu
|
|
@@ -965,27 +983,23 @@ class PermissionService {
|
|
|
965
983
|
if (permission === PERMISSION_NAMES.SubscriptionSuperOwner) {
|
|
966
984
|
return this.isUserSubscriptionSuperOwner() || this.isSuperAdmin();
|
|
967
985
|
}
|
|
968
|
-
if (typeof permission ===
|
|
986
|
+
if (typeof permission === 'string' &&
|
|
969
987
|
ADMIN_SUB_MENU_WHITELIST.some(v => permission.includes(v)) &&
|
|
970
988
|
(this.isUserSubscriptionSuperAdmin() || this.isUserSubscriptionSuperOwner())) {
|
|
971
989
|
return true;
|
|
972
990
|
}
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
}
|
|
986
|
-
expr += `${raw} `;
|
|
987
|
-
}, this);
|
|
988
|
-
}
|
|
991
|
+
const tokens = (permission || '').toString().split(' ').filter(Boolean);
|
|
992
|
+
tokens.forEach(token => {
|
|
993
|
+
const rawToken = token.trim();
|
|
994
|
+
if (rawToken === '||' || rawToken === '&&' || rawToken === '(' || rawToken === ')') {
|
|
995
|
+
expr += ` ${rawToken} `;
|
|
996
|
+
}
|
|
997
|
+
else {
|
|
998
|
+
// it's a permission name (either 'SubscriptionAdmin', 'Pages.Role.MarketingManager', etc.)
|
|
999
|
+
const evaluated = this.isGranted(rawToken, productKey, permission_key, productSlug);
|
|
1000
|
+
expr += ` ${evaluated} `;
|
|
1001
|
+
}
|
|
1002
|
+
});
|
|
989
1003
|
// eslint-disable-next-line no-eval
|
|
990
1004
|
// NOSONAR: Trusted eval function is handled safely here
|
|
991
1005
|
return eval(expr); // NOSONAR
|
|
@@ -1034,8 +1048,7 @@ class PermissionService {
|
|
|
1034
1048
|
if (!product) {
|
|
1035
1049
|
product = this.getCurrentProduct();
|
|
1036
1050
|
}
|
|
1037
|
-
const
|
|
1038
|
-
const subscriptionSlug = selectedProduct?.subscription_slug;
|
|
1051
|
+
const subscriptionSlug = product?.subscription_slug;
|
|
1039
1052
|
return (!!this.user.auth.granted[`Pages.Product.${subscriptionSlug}.${product.permission_key}.${product.feature_key}.SubscriptionSuperAdmin`] ||
|
|
1040
1053
|
!!this.user.auth.granted[`Pages.Product.${subscriptionSlug}.${product.permission_key}.${product.feature_key}.SubscriptionSuperOwner`]);
|
|
1041
1054
|
}
|
|
@@ -1963,11 +1976,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImpo
|
|
|
1963
1976
|
class GroupService {
|
|
1964
1977
|
constructor(api) {
|
|
1965
1978
|
this.api = api;
|
|
1966
|
-
this.ADMIN_PATH = ADMIN_PATH;
|
|
1967
1979
|
this.subscription_endpoint = '/subscriptions/';
|
|
1968
1980
|
this.group_communications_endpoint = '/group_communications/';
|
|
1969
1981
|
this.group_definitions_endpoint = '/group_definitions/';
|
|
1970
1982
|
this.groups_endpoint = '/groups/';
|
|
1983
|
+
this.ADMIN_PATH = ADMIN_PATH;
|
|
1971
1984
|
}
|
|
1972
1985
|
// ------------------------------------------------------------
|
|
1973
1986
|
// Subscription Service
|
|
@@ -2202,8 +2215,8 @@ class NotificationService {
|
|
|
2202
2215
|
this.api = api;
|
|
2203
2216
|
this.toastrService = toastrService;
|
|
2204
2217
|
this.socketService = socketService;
|
|
2205
|
-
this.endpoint = 'notes_read';
|
|
2206
2218
|
this.notificationSubject$ = new BehaviorSubject([]);
|
|
2219
|
+
this.endpoint = 'notes_read';
|
|
2207
2220
|
}
|
|
2208
2221
|
getNotifications(paging) {
|
|
2209
2222
|
return this.api.getWithParams(`/notes?show_on_dashboard=true`, {
|