@posiwise/common-services 0.1.92 → 0.1.94
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.
|
@@ -1353,7 +1353,7 @@ class PermissionService {
|
|
|
1353
1353
|
// or Pages.Beta or Pages.Alpha
|
|
1354
1354
|
if (permissionName?.includes('||')) {
|
|
1355
1355
|
const parts = permissionName.split('||').map(p => p.trim());
|
|
1356
|
-
if (this.hasAnyGrantedPermission(parts, user)) {
|
|
1356
|
+
if (this.hasAnyGrantedPermission(parts, user, productSlug)) {
|
|
1357
1357
|
return true;
|
|
1358
1358
|
}
|
|
1359
1359
|
}
|
|
@@ -1370,8 +1370,12 @@ class PermissionService {
|
|
|
1370
1370
|
// user not logged-in
|
|
1371
1371
|
return false;
|
|
1372
1372
|
}
|
|
1373
|
-
hasAnyGrantedPermission(parts, user) {
|
|
1374
|
-
return parts.some(part =>
|
|
1373
|
+
hasAnyGrantedPermission(parts, user, productSlug = null) {
|
|
1374
|
+
return parts.some(part => {
|
|
1375
|
+
// Format the permission part with the current subscription slug if needed
|
|
1376
|
+
const formattedPart = this.getFormattedPermissionName(part, productSlug);
|
|
1377
|
+
return user['auth']?.['granted'][formattedPart];
|
|
1378
|
+
});
|
|
1375
1379
|
}
|
|
1376
1380
|
handleProductKey(productKey, user, permission_key, permissionName) {
|
|
1377
1381
|
if (productKey) {
|
|
@@ -1403,11 +1407,15 @@ class PermissionService {
|
|
|
1403
1407
|
else {
|
|
1404
1408
|
slugToCheck = productSlug;
|
|
1405
1409
|
}
|
|
1406
|
-
if
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1410
|
+
// Only format if we have a valid slug to check
|
|
1411
|
+
if (slugToCheck) {
|
|
1412
|
+
if (!permissionName.includes(slugToCheck) &&
|
|
1413
|
+
permissionName.includes('Pages.Product.')) {
|
|
1414
|
+
permissionName = permissionName.replace('Pages.Product.', slugToCheck);
|
|
1415
|
+
}
|
|
1416
|
+
if (permissionName.includes('Pages.Role.') && !permissionName.includes(slugToCheck)) {
|
|
1417
|
+
permissionName = permissionName.replace('Pages.Role.', slugToCheck);
|
|
1418
|
+
}
|
|
1411
1419
|
}
|
|
1412
1420
|
return permissionName;
|
|
1413
1421
|
}
|
|
@@ -1492,7 +1500,8 @@ class PermissionService {
|
|
|
1492
1500
|
evaluated = this.isGranted(raw, productKey, permission_key, productSlug);
|
|
1493
1501
|
}
|
|
1494
1502
|
else {
|
|
1495
|
-
|
|
1503
|
+
// Pass productSlug to isGranted to ensure slug-aware permission checking
|
|
1504
|
+
evaluated = this.isGranted(raw, null, null, productSlug);
|
|
1496
1505
|
}
|
|
1497
1506
|
expr += ` ${evaluated} `;
|
|
1498
1507
|
}
|