@optimiser/common 1.0.412 → 1.0.413

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.
@@ -305,7 +305,7 @@ declare function GetFileFolderDetailsInFolderForDriveSharing(parentFolderID: any
305
305
  * @return NA
306
306
  */
307
307
  declare function SyncTotalSlotRemaining(registrationID: any, db: Db): Promise<void>;
308
- declare function CheckAccessPermissions(permissionType: string, objectName: string, msp_d: AnyObjectInterface, db: Db, mdb: Db, next: NextFunction): Promise<boolean | undefined>;
308
+ declare function CheckAccessPermissions(permissionType: string, objectName: string, pageName: string, msp_d: AnyObjectInterface, db: Db, mdb: Db, next: NextFunction): Promise<boolean | undefined>;
309
309
  /**
310
310
  * TODO: To Set the delay
311
311
  *
@@ -5796,48 +5796,42 @@ function ValidateStateCountryField(_a) {
5796
5796
  * Example: If user has Create/Modify/Delete/Import permission let him procceed else stop access.
5797
5797
  * Return: true/false
5798
5798
  */
5799
- function CheckAccessPermissions(permissionType, objectName, msp_d, db, mdb, next) {
5800
- var _a, _b, _c;
5799
+ function CheckAccessPermissions(permissionType, objectName, pageName, msp_d, db, mdb, next) {
5800
+ var _a, _b, _c, _d, _e;
5801
5801
  return __awaiter(this, void 0, void 0, function () {
5802
- var response, isAllowed, data, _i, _d, item, error_9;
5803
- return __generator(this, function (_e) {
5804
- switch (_e.label) {
5802
+ var response, isAllowed, data, _i, _f, item, error_9;
5803
+ return __generator(this, function (_g) {
5804
+ switch (_g.label) {
5805
5805
  case 0:
5806
- _e.trys.push([0, 2, , 3]);
5806
+ _g.trys.push([0, 2, , 3]);
5807
5807
  return [4 /*yield*/, GetUserProfile(msp_d, db, mdb, next)];
5808
5808
  case 1:
5809
- response = _e.sent();
5809
+ response = _g.sent();
5810
5810
  isAllowed = false;
5811
5811
  data = response === null || response === void 0 ? void 0 : response.data;
5812
5812
  if (data && data.Permissions.length > 0) {
5813
- for (_i = 0, _d = data.Permissions; _i < _d.length; _i++) {
5814
- item = _d[_i];
5815
- if (item.ModuleID.toLowerCase() == objectName.toLowerCase() || ((_b = (_a = item.ModuleData) === null || _a === void 0 ? void 0 : _a.Objects) === null || _b === void 0 ? void 0 : _b.includes(objectName))) {
5813
+ for (_i = 0, _f = data.Permissions; _i < _f.length; _i++) {
5814
+ item = _f[_i];
5815
+ if (item.ModuleID.toLowerCase() == objectName.toLowerCase() || ((_b = (_a = item.ModuleData) === null || _a === void 0 ? void 0 : _a.Objects) === null || _b === void 0 ? void 0 : _b.includes(objectName)) || (pageName && ((_d = (_c = item.ModuleData) === null || _c === void 0 ? void 0 : _c.Pages) === null || _d === void 0 ? void 0 : _d.includes(pageName)))) {
5816
5816
  if (permissionType == "CheckOnlyAccess") {
5817
5817
  isAllowed = true;
5818
- break;
5819
5818
  }
5820
5819
  else if (item.Operations.includes(permissionType)) {
5821
5820
  isAllowed = true;
5822
- break;
5823
5821
  }
5824
- else if (((_c = item.ModuleData) === null || _c === void 0 ? void 0 : _c.CheckOnlyControlPanel) && item.Operations.includes('Control Panel')) {
5822
+ else if (((_e = item.ModuleData) === null || _e === void 0 ? void 0 : _e.CheckOnlyControlPanel) && item.Operations.includes('Control Panel')) {
5825
5823
  isAllowed = true;
5826
- break;
5827
5824
  }
5828
5825
  else if (item.ModuleID == "report" && item.Operations.includes('Create-Edit')) {
5829
5826
  isAllowed = true;
5830
- break;
5831
5827
  }
5828
+ break;
5832
5829
  }
5833
5830
  }
5834
5831
  }
5835
- else if ((response === null || response === void 0 ? void 0 : response.message) != 'success') { // Else if was added by Shahzaib not to allow user to perform CRUD operation with inactive licence.
5836
- isAllowed = false;
5837
- }
5838
5832
  return [2 /*return*/, isAllowed];
5839
5833
  case 2:
5840
- error_9 = _e.sent();
5834
+ error_9 = _g.sent();
5841
5835
  console.error("Internal Error in CheckAccessPermissions function : ".concat(error_9));
5842
5836
  return [3 /*break*/, 3];
5843
5837
  case 3: return [2 /*return*/];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.412",
3
+ "version": "1.0.413",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {