@optimiser/common 1.0.229 → 1.0.233
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/dist/lib/utility.d.ts +3 -1
- package/dist/lib/utility.js +130 -67
- package/package.json +1 -1
package/dist/lib/utility.d.ts
CHANGED
|
@@ -175,6 +175,8 @@ declare function GetUserProfile(msp_d: AnyObjectInterface, db: Db, mdb: Db, next
|
|
|
175
175
|
message: string;
|
|
176
176
|
data: any;
|
|
177
177
|
} | undefined>;
|
|
178
|
+
declare function CheckPageAuthentication(pageData: AnyObjectInterface, msp_d: AnyObjectInterface, db: Db, mdb: Db, next: NextFunction): Promise<boolean>;
|
|
179
|
+
declare function RemoveFieldsFromFilters(condition: AnyObjectInterface, fields: AnyObjectInterface[]): void;
|
|
178
180
|
/**
|
|
179
181
|
* @param Error Error object
|
|
180
182
|
* @param ServiceOrigin - Error Occur in Service (Service Name)
|
|
@@ -186,4 +188,4 @@ declare function GetUserProfile(msp_d: AnyObjectInterface, db: Db, mdb: Db, next
|
|
|
186
188
|
declare function ErrorHandlerForServices(Error: OPT_ERROR, ServiceOrigin: string, EmailConfig: any, Module?: string, db?: Db): Promise<any>;
|
|
187
189
|
declare function CheckCaptcha(token: string, captcha: string, redisClient: Redis): Promise<unknown>;
|
|
188
190
|
declare function ValidateSanitizeUserInput(inputFields: AnyObjectInterface, pageData: AnyObjectInterface): Promise<AnyObjectInterface[] | undefined>;
|
|
189
|
-
export { CheckForWhiteListedDomain, ReturnJsonResponse, ConvertFileByteSize, GetObjectByKeyValueFromList, IsEqualArrays, IsEqualValue, CheckUserProfileField, GetPageFieldData, GetPageObjectSchema, GetFieldDetail, UpdateRecentViewObject, SyncChildObjectData, SyncParentObjectData, DeleteFieldInOtherCollection, SyncFieldInSameCollection, SyncFieldInSameCollectionByObjectID, SyncFieldInSameCollectionByObjectIDWithPromise, SyncFieldInOtherCollection, SyncUserInOtherCollection, BuildLookupDataField, CheckDataBeforeAdd, CheckDataBeforeUpdate, BuildGridFieldProjection, BuildFieldProjection, BuildLookupFieldProjection, FilterConditions, GirdHeaderFilters, AddLog, CheckFilterFieldsProjection, VerifyEmailPassword, GetMyTeamUsers, ExtractChildUsersTree, GetMaxKeyValueListSchema, VerifyAWSEmailConfig, GenerateId, SyncUserDetailsWithMasterDB, SignoutUserFromAllDevices, SignoutUsersWithPromise, SignoutMultipleUsersFromAllDevices, UserLicenseConsumeCalculate, sendMailWithUserAccount, GetEmailClientConfigs, GetCompanyEncryptionKey, ExecuteDynamicDMLQuery, ExecuteDynamicDQLQuery, GetUserProfilePermissions, MakeUserPasswordInvalid, ConvertJsonToXLXS, SendResetPasswordMail, SendMailToSupport, MailTemplateStructure, SendMailToCustomer, parseMSPCookie, GetIPDetailsFromReq, isEmptyObj, SyncListSchemaFieldInOtherCollection, UpdateTagCountAfterDelete, SyncTagCountAfterUpdate, ReactivateFieldInOtherCollection, SyncUserLicenceConsumedCount, BroadCastEventToAllCompanyUsers, CheckDataPermission, SyncCompanyLicenceInMasterCompanyAfterAdd, NextServiceDateForDashboard, CheckDateNotInPast, GetWeekDayByDayAndOccurance, GetInterValFromOccurance, GetWeekDayInfoInMonth, GetDayIndex, GetUserProfile, ErrorHandlerForServices, CheckCaptcha, ValidateSanitizeUserInput };
|
|
191
|
+
export { CheckForWhiteListedDomain, ReturnJsonResponse, ConvertFileByteSize, GetObjectByKeyValueFromList, IsEqualArrays, IsEqualValue, CheckUserProfileField, GetPageFieldData, GetPageObjectSchema, GetFieldDetail, UpdateRecentViewObject, SyncChildObjectData, SyncParentObjectData, DeleteFieldInOtherCollection, SyncFieldInSameCollection, SyncFieldInSameCollectionByObjectID, SyncFieldInSameCollectionByObjectIDWithPromise, SyncFieldInOtherCollection, SyncUserInOtherCollection, BuildLookupDataField, CheckDataBeforeAdd, CheckDataBeforeUpdate, BuildGridFieldProjection, BuildFieldProjection, BuildLookupFieldProjection, FilterConditions, GirdHeaderFilters, AddLog, CheckFilterFieldsProjection, VerifyEmailPassword, GetMyTeamUsers, ExtractChildUsersTree, GetMaxKeyValueListSchema, VerifyAWSEmailConfig, GenerateId, SyncUserDetailsWithMasterDB, SignoutUserFromAllDevices, SignoutUsersWithPromise, SignoutMultipleUsersFromAllDevices, UserLicenseConsumeCalculate, sendMailWithUserAccount, GetEmailClientConfigs, GetCompanyEncryptionKey, ExecuteDynamicDMLQuery, ExecuteDynamicDQLQuery, GetUserProfilePermissions, MakeUserPasswordInvalid, ConvertJsonToXLXS, SendResetPasswordMail, SendMailToSupport, MailTemplateStructure, SendMailToCustomer, parseMSPCookie, GetIPDetailsFromReq, isEmptyObj, SyncListSchemaFieldInOtherCollection, UpdateTagCountAfterDelete, SyncTagCountAfterUpdate, ReactivateFieldInOtherCollection, SyncUserLicenceConsumedCount, BroadCastEventToAllCompanyUsers, CheckDataPermission, SyncCompanyLicenceInMasterCompanyAfterAdd, NextServiceDateForDashboard, CheckDateNotInPast, GetWeekDayByDayAndOccurance, GetInterValFromOccurance, GetWeekDayInfoInMonth, GetDayIndex, RemoveFieldsFromFilters, GetUserProfile, CheckPageAuthentication, ErrorHandlerForServices, CheckCaptcha, ValidateSanitizeUserInput };
|
package/dist/lib/utility.js
CHANGED
|
@@ -80,7 +80,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
80
80
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
81
81
|
};
|
|
82
82
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
83
|
-
exports.ValidateSanitizeUserInput = exports.CheckCaptcha = exports.ErrorHandlerForServices = exports.GetUserProfile = exports.GetDayIndex = exports.GetWeekDayInfoInMonth = exports.GetInterValFromOccurance = exports.GetWeekDayByDayAndOccurance = exports.CheckDateNotInPast = exports.NextServiceDateForDashboard = exports.SyncCompanyLicenceInMasterCompanyAfterAdd = exports.CheckDataPermission = exports.BroadCastEventToAllCompanyUsers = exports.SyncUserLicenceConsumedCount = exports.ReactivateFieldInOtherCollection = exports.SyncTagCountAfterUpdate = exports.UpdateTagCountAfterDelete = exports.SyncListSchemaFieldInOtherCollection = exports.isEmptyObj = exports.GetIPDetailsFromReq = exports.parseMSPCookie = exports.SendMailToCustomer = exports.MailTemplateStructure = exports.SendMailToSupport = exports.SendResetPasswordMail = exports.ConvertJsonToXLXS = exports.MakeUserPasswordInvalid = exports.GetUserProfilePermissions = exports.ExecuteDynamicDQLQuery = exports.ExecuteDynamicDMLQuery = exports.GetCompanyEncryptionKey = exports.GetEmailClientConfigs = exports.sendMailWithUserAccount = exports.UserLicenseConsumeCalculate = exports.SignoutMultipleUsersFromAllDevices = exports.SignoutUsersWithPromise = exports.SignoutUserFromAllDevices = exports.SyncUserDetailsWithMasterDB = exports.GenerateId = exports.VerifyAWSEmailConfig = exports.GetMaxKeyValueListSchema = exports.ExtractChildUsersTree = exports.GetMyTeamUsers = exports.VerifyEmailPassword = exports.CheckFilterFieldsProjection = exports.AddLog = exports.GirdHeaderFilters = exports.FilterConditions = exports.BuildLookupFieldProjection = exports.BuildFieldProjection = exports.BuildGridFieldProjection = exports.CheckDataBeforeUpdate = exports.CheckDataBeforeAdd = exports.BuildLookupDataField = exports.SyncUserInOtherCollection = exports.SyncFieldInOtherCollection = exports.SyncFieldInSameCollectionByObjectIDWithPromise = exports.SyncFieldInSameCollectionByObjectID = exports.SyncFieldInSameCollection = exports.DeleteFieldInOtherCollection = exports.SyncParentObjectData = exports.SyncChildObjectData = exports.UpdateRecentViewObject = exports.GetFieldDetail = exports.GetPageObjectSchema = exports.GetPageFieldData = exports.CheckUserProfileField = exports.IsEqualValue = exports.IsEqualArrays = exports.GetObjectByKeyValueFromList = exports.ConvertFileByteSize = exports.ReturnJsonResponse = exports.CheckForWhiteListedDomain = void 0;
|
|
83
|
+
exports.ValidateSanitizeUserInput = exports.CheckCaptcha = exports.ErrorHandlerForServices = exports.CheckPageAuthentication = exports.GetUserProfile = exports.RemoveFieldsFromFilters = exports.GetDayIndex = exports.GetWeekDayInfoInMonth = exports.GetInterValFromOccurance = exports.GetWeekDayByDayAndOccurance = exports.CheckDateNotInPast = exports.NextServiceDateForDashboard = exports.SyncCompanyLicenceInMasterCompanyAfterAdd = exports.CheckDataPermission = exports.BroadCastEventToAllCompanyUsers = exports.SyncUserLicenceConsumedCount = exports.ReactivateFieldInOtherCollection = exports.SyncTagCountAfterUpdate = exports.UpdateTagCountAfterDelete = exports.SyncListSchemaFieldInOtherCollection = exports.isEmptyObj = exports.GetIPDetailsFromReq = exports.parseMSPCookie = exports.SendMailToCustomer = exports.MailTemplateStructure = exports.SendMailToSupport = exports.SendResetPasswordMail = exports.ConvertJsonToXLXS = exports.MakeUserPasswordInvalid = exports.GetUserProfilePermissions = exports.ExecuteDynamicDQLQuery = exports.ExecuteDynamicDMLQuery = exports.GetCompanyEncryptionKey = exports.GetEmailClientConfigs = exports.sendMailWithUserAccount = exports.UserLicenseConsumeCalculate = exports.SignoutMultipleUsersFromAllDevices = exports.SignoutUsersWithPromise = exports.SignoutUserFromAllDevices = exports.SyncUserDetailsWithMasterDB = exports.GenerateId = exports.VerifyAWSEmailConfig = exports.GetMaxKeyValueListSchema = exports.ExtractChildUsersTree = exports.GetMyTeamUsers = exports.VerifyEmailPassword = exports.CheckFilterFieldsProjection = exports.AddLog = exports.GirdHeaderFilters = exports.FilterConditions = exports.BuildLookupFieldProjection = exports.BuildFieldProjection = exports.BuildGridFieldProjection = exports.CheckDataBeforeUpdate = exports.CheckDataBeforeAdd = exports.BuildLookupDataField = exports.SyncUserInOtherCollection = exports.SyncFieldInOtherCollection = exports.SyncFieldInSameCollectionByObjectIDWithPromise = exports.SyncFieldInSameCollectionByObjectID = exports.SyncFieldInSameCollection = exports.DeleteFieldInOtherCollection = exports.SyncParentObjectData = exports.SyncChildObjectData = exports.UpdateRecentViewObject = exports.GetFieldDetail = exports.GetPageObjectSchema = exports.GetPageFieldData = exports.CheckUserProfileField = exports.IsEqualValue = exports.IsEqualArrays = exports.GetObjectByKeyValueFromList = exports.ConvertFileByteSize = exports.ReturnJsonResponse = exports.CheckForWhiteListedDomain = void 0;
|
|
84
84
|
var moment_1 = __importDefault(require("moment"));
|
|
85
85
|
var nodemailer_1 = __importDefault(require("nodemailer"));
|
|
86
86
|
var mongodb_1 = require("mongodb");
|
|
@@ -88,13 +88,13 @@ var bson_1 = require("bson");
|
|
|
88
88
|
var Excel = __importStar(require("exceljs"));
|
|
89
89
|
var path_1 = __importDefault(require("path"));
|
|
90
90
|
var fs_1 = __importDefault(require("fs"));
|
|
91
|
-
var
|
|
91
|
+
var geoip = __importStar(require("geoip-lite"));
|
|
92
92
|
var crypto_1 = __importDefault(require("crypto"));
|
|
93
93
|
var constants_1 = __importDefault(require("../constants"));
|
|
94
94
|
var mail_1 = require("../utility/mail");
|
|
95
95
|
var errorHandlerForServices_1 = __importDefault(require("../utility/errorHandlerForServices"));
|
|
96
96
|
var cryptoService = __importStar(require("../utility/crypto"));
|
|
97
|
-
var
|
|
97
|
+
var countrycode_1 = require("./countrycode");
|
|
98
98
|
require("moment-timezone");
|
|
99
99
|
var sanitize = require('mongo-sanitize');
|
|
100
100
|
function GetObjectByKeyValueFromList(list, key, val) {
|
|
@@ -185,11 +185,10 @@ function CheckUserProfileField(pageData, profileData) {
|
|
|
185
185
|
exports.CheckUserProfileField = CheckUserProfileField;
|
|
186
186
|
function GetPageFieldData(pageName, db, mdb, msp_d, next, callback) {
|
|
187
187
|
db.collection("Page").findOne({ 'PageName': pageName }, function (err, pageData) {
|
|
188
|
-
var _a, _b;
|
|
189
188
|
return __awaiter(this, void 0, void 0, function () {
|
|
190
|
-
var hasAccess
|
|
191
|
-
return __generator(this, function (
|
|
192
|
-
switch (
|
|
189
|
+
var hasAccess;
|
|
190
|
+
return __generator(this, function (_a) {
|
|
191
|
+
switch (_a.label) {
|
|
193
192
|
case 0:
|
|
194
193
|
if (err) {
|
|
195
194
|
next(err);
|
|
@@ -198,40 +197,16 @@ function GetPageFieldData(pageName, db, mdb, msp_d, next, callback) {
|
|
|
198
197
|
callback(pageData);
|
|
199
198
|
return [2 /*return*/];
|
|
200
199
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
hasAccess =
|
|
204
|
-
return [3 /*break*/, 3];
|
|
205
|
-
case 1: return [4 /*yield*/, GetUserProfile(msp_d, db, mdb, next)];
|
|
206
|
-
case 2:
|
|
207
|
-
response = _c.sent();
|
|
208
|
-
if (response && response.message == 'success') {
|
|
209
|
-
userProfile = response.data;
|
|
210
|
-
auth = userProfile.Permissions;
|
|
211
|
-
for (i = 0; i < auth.length; i++) {
|
|
212
|
-
moduleData = auth[i].ModuleData;
|
|
213
|
-
if (moduleData) {
|
|
214
|
-
if (((_a = moduleData.Objects) === null || _a === void 0 ? void 0 : _a.indexOf(pageData.ObjectName)) >= 0 || ((_b = moduleData.Pages) === null || _b === void 0 ? void 0 : _b.indexOf(pageData.PageName)) >= 0) {
|
|
215
|
-
hasAccess = true;
|
|
216
|
-
break;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
else {
|
|
222
|
-
console.log(response === null || response === void 0 ? void 0 : response.message);
|
|
223
|
-
callback('Unauthorised');
|
|
224
|
-
}
|
|
225
|
-
_c.label = 3;
|
|
226
|
-
case 3:
|
|
227
|
-
// ** Ends ** //
|
|
200
|
+
return [4 /*yield*/, CheckPageAuthentication(pageData, msp_d, db, mdb, next)];
|
|
201
|
+
case 1:
|
|
202
|
+
hasAccess = _a.sent();
|
|
228
203
|
if (!hasAccess) {
|
|
229
204
|
callback('Unauthorised');
|
|
230
205
|
}
|
|
231
206
|
else {
|
|
232
207
|
db.collection("ObjectSchema").findOne({ 'Name': pageData.ObjectName }, function (err, objectData) {
|
|
233
208
|
return __awaiter(this, void 0, void 0, function () {
|
|
234
|
-
var _loop_2, i, g, group, childObjectSchema, _loop_3, i, _loop_4, i;
|
|
209
|
+
var removeFieldsFromFilter, j, filterData, _loop_2, i, g, group, childObjectSchema, _loop_3, i, _loop_4, i, idObject, idObject_1;
|
|
235
210
|
return __generator(this, function (_a) {
|
|
236
211
|
switch (_a.label) {
|
|
237
212
|
case 0:
|
|
@@ -239,6 +214,14 @@ function GetPageFieldData(pageName, db, mdb, msp_d, next, callback) {
|
|
|
239
214
|
next(err);
|
|
240
215
|
}
|
|
241
216
|
pageData["ObjectSchema"] = objectData;
|
|
217
|
+
removeFieldsFromFilter = objectData.Fields.filter(function (f) { return f.IsFilter == false; }).map(function (fld) { return fld.Name; });
|
|
218
|
+
if (removeFieldsFromFilter && pageData.ListViewFilters && removeFieldsFromFilter.length > 0 && pageData.ListViewFilters.length > 0) {
|
|
219
|
+
for (j = 0; j < pageData.ListViewFilters.length; j++) {
|
|
220
|
+
filterData = pageData.ListViewFilters[j];
|
|
221
|
+
RemoveFieldsFromFilters(filterData.Conditions, removeFieldsFromFilter);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
//** Ends */
|
|
242
225
|
if (pageData.Fields != undefined) {
|
|
243
226
|
_loop_2 = function (i) {
|
|
244
227
|
var fld = pageData.Fields[i];
|
|
@@ -294,6 +277,34 @@ function GetPageFieldData(pageName, db, mdb, msp_d, next, callback) {
|
|
|
294
277
|
g++;
|
|
295
278
|
return [3 /*break*/, 1];
|
|
296
279
|
case 5:
|
|
280
|
+
if (pageData.Fields && pageData.Type == "ObjectGrid") {
|
|
281
|
+
idObject = {
|
|
282
|
+
Name: "_id",
|
|
283
|
+
Schema: { Name: "_id", DisplayName: "ID", ApiName: "ID", UIDataType: "objectid" },
|
|
284
|
+
Sequence: 0,
|
|
285
|
+
UniqueID: "_id",
|
|
286
|
+
DisplayName: "ID",
|
|
287
|
+
Width: 100
|
|
288
|
+
};
|
|
289
|
+
pageData.Fields.splice(0, 0, idObject);
|
|
290
|
+
}
|
|
291
|
+
if (pageData.Fields && pageData.Type == "ObjectDetail") {
|
|
292
|
+
idObject_1 = {
|
|
293
|
+
Name: "_id",
|
|
294
|
+
Sequence: 0,
|
|
295
|
+
UIDataType: "objectid",
|
|
296
|
+
UniqueID: "_id",
|
|
297
|
+
DisplayName: "ID"
|
|
298
|
+
};
|
|
299
|
+
pageData.Fields == pageData.Fields.map(function (s) {
|
|
300
|
+
if (s.Schema && s.Schema.UIDataType == "collection") {
|
|
301
|
+
s.Schema.Fields.splice(0, 0, idObject_1);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
s;
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
}
|
|
297
308
|
callback(pageData);
|
|
298
309
|
return [2 /*return*/];
|
|
299
310
|
}
|
|
@@ -2034,6 +2045,8 @@ function GirdHeaderFilters(filters, fields) {
|
|
|
2034
2045
|
matchValue = { '$eq': parseInt(obj.Value) };
|
|
2035
2046
|
else if (["decimal", "percent"].includes(field.Schema.UIDataType))
|
|
2036
2047
|
matchValue = { '$eq': mongodb_1.Decimal128.fromString(obj.Value) };
|
|
2048
|
+
else if (field.Schema.UIDataType == 'objectid')
|
|
2049
|
+
matchValue = { '$eq': obj.Value };
|
|
2037
2050
|
else
|
|
2038
2051
|
matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
|
|
2039
2052
|
var fieldMatch = {};
|
|
@@ -2973,40 +2986,39 @@ function ConvertFileByteSize(bytes) {
|
|
|
2973
2986
|
exports.ConvertFileByteSize = ConvertFileByteSize;
|
|
2974
2987
|
function GetIPDetailsFromReq(req) {
|
|
2975
2988
|
return __awaiter(this, void 0, void 0, function () {
|
|
2976
|
-
var ip,
|
|
2989
|
+
var ip, ipDetails;
|
|
2977
2990
|
return __generator(this, function (_a) {
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
console.log("In req.headers['x-original-forwarded-for']"); /* Temp for brijesh */
|
|
2982
|
-
ip = req.headers['x-original-forwarded-for'];
|
|
2983
|
-
}
|
|
2984
|
-
else if (req.headers['x-forwarded-for']) {
|
|
2985
|
-
console.log("In req.headers['x-forwarded-for']"); /* Temp for brijesh */
|
|
2986
|
-
ip = req.headers['x-forwarded-for'].split(",")[0];
|
|
2987
|
-
}
|
|
2988
|
-
else if (req.connection && req.connection.remoteAddress) {
|
|
2989
|
-
ip = req.connection.remoteAddress;
|
|
2990
|
-
}
|
|
2991
|
-
else {
|
|
2992
|
-
ip = req.ip;
|
|
2993
|
-
}
|
|
2994
|
-
domainName = req.headers.host ? req.headers.host : req.headers.origin;
|
|
2995
|
-
return [4 /*yield*/, axios_1.default.post("https://" + domainName + "/user/noauth/getlocationfromip", { ip: ip }, {
|
|
2996
|
-
httpsAgent: new https_1.default.Agent({
|
|
2997
|
-
rejectUnauthorized: false
|
|
2998
|
-
})
|
|
2999
|
-
})];
|
|
3000
|
-
case 1:
|
|
3001
|
-
ipDetails = (_a.sent()).data;
|
|
3002
|
-
ipDetails = ipDetails.data;
|
|
3003
|
-
/* if (ipDetails) {
|
|
3004
|
-
ipDetails.countryName = countryCode(ipDetails.country)
|
|
3005
|
-
ipDetails.ip = ip
|
|
3006
|
-
} */
|
|
3007
|
-
console.log('>>IP DE ', ipDetails);
|
|
3008
|
-
return [2 /*return*/, ipDetails];
|
|
2991
|
+
if (req.headers['x-original-forwarded-for']) {
|
|
2992
|
+
//console.log("In req.headers['x-original-forwarded-for']");
|
|
2993
|
+
ip = req.headers['x-original-forwarded-for'];
|
|
3009
2994
|
}
|
|
2995
|
+
else if (req.headers['x-forwarded-for']) {
|
|
2996
|
+
//console.log("In req.headers['x-forwarded-for']");
|
|
2997
|
+
ip = req.headers['x-forwarded-for'].split(",")[0];
|
|
2998
|
+
}
|
|
2999
|
+
else if (req.connection && req.connection.remoteAddress) {
|
|
3000
|
+
ip = req.connection.remoteAddress;
|
|
3001
|
+
}
|
|
3002
|
+
else {
|
|
3003
|
+
ip = req.ip;
|
|
3004
|
+
}
|
|
3005
|
+
ipDetails = geoip.lookup(ip);
|
|
3006
|
+
if (ipDetails) {
|
|
3007
|
+
ipDetails.countryName = countrycode_1.getCountryFromCode(ipDetails.country);
|
|
3008
|
+
ipDetails.ip = ip;
|
|
3009
|
+
// }
|
|
3010
|
+
//return connection.ReturnJsonResponse(req, res, { Status: 200, Message: 'success', Data: ipDetails, Type: 'POST', LogData: false });
|
|
3011
|
+
}
|
|
3012
|
+
else {
|
|
3013
|
+
ipDetails = '';
|
|
3014
|
+
}
|
|
3015
|
+
//ipDetails = ipDetails.data;
|
|
3016
|
+
/* if (ipDetails) {
|
|
3017
|
+
ipDetails.countryName = countryCode(ipDetails.country)
|
|
3018
|
+
ipDetails.ip = ip
|
|
3019
|
+
} */
|
|
3020
|
+
console.log('>>IP DE ', ipDetails);
|
|
3021
|
+
return [2 /*return*/, ipDetails];
|
|
3010
3022
|
});
|
|
3011
3023
|
});
|
|
3012
3024
|
}
|
|
@@ -3765,6 +3777,57 @@ function GetUserProfile(msp_d, db, mdb, next) {
|
|
|
3765
3777
|
});
|
|
3766
3778
|
}
|
|
3767
3779
|
exports.GetUserProfile = GetUserProfile;
|
|
3780
|
+
function CheckPageAuthentication(pageData, msp_d, db, mdb, next) {
|
|
3781
|
+
var _a, _b;
|
|
3782
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3783
|
+
var hasAccess, response, userProfile, auth, i, moduleData;
|
|
3784
|
+
return __generator(this, function (_c) {
|
|
3785
|
+
switch (_c.label) {
|
|
3786
|
+
case 0:
|
|
3787
|
+
hasAccess = false;
|
|
3788
|
+
if (!(pageData.IsPermissionRequired == false)) return [3 /*break*/, 1];
|
|
3789
|
+
hasAccess = true;
|
|
3790
|
+
return [3 /*break*/, 3];
|
|
3791
|
+
case 1: return [4 /*yield*/, GetUserProfile(msp_d, db, mdb, next)];
|
|
3792
|
+
case 2:
|
|
3793
|
+
response = _c.sent();
|
|
3794
|
+
if (response && response.message == 'success') {
|
|
3795
|
+
userProfile = response.data;
|
|
3796
|
+
auth = userProfile.Permissions;
|
|
3797
|
+
for (i = 0; i < auth.length; i++) {
|
|
3798
|
+
moduleData = auth[i].ModuleData;
|
|
3799
|
+
if (moduleData) {
|
|
3800
|
+
if (((_a = moduleData.Objects) === null || _a === void 0 ? void 0 : _a.indexOf(pageData.ObjectName)) >= 0 || ((_b = moduleData.Pages) === null || _b === void 0 ? void 0 : _b.indexOf(pageData.PageName)) >= 0) {
|
|
3801
|
+
hasAccess = true;
|
|
3802
|
+
break;
|
|
3803
|
+
}
|
|
3804
|
+
}
|
|
3805
|
+
}
|
|
3806
|
+
}
|
|
3807
|
+
else {
|
|
3808
|
+
console.log(response === null || response === void 0 ? void 0 : response.message);
|
|
3809
|
+
}
|
|
3810
|
+
_c.label = 3;
|
|
3811
|
+
case 3: return [2 /*return*/, hasAccess];
|
|
3812
|
+
}
|
|
3813
|
+
});
|
|
3814
|
+
});
|
|
3815
|
+
}
|
|
3816
|
+
exports.CheckPageAuthentication = CheckPageAuthentication;
|
|
3817
|
+
function RemoveFieldsFromFilters(condition, fields) {
|
|
3818
|
+
if (condition != undefined && condition.Filters.length > 0) {
|
|
3819
|
+
fields.forEach(function (field) {
|
|
3820
|
+
condition.Filters = condition.Filters.filter(function (fltr) { return fltr.Name !== field; });
|
|
3821
|
+
});
|
|
3822
|
+
for (var i = 0; i < condition.Filters.length; i++) {
|
|
3823
|
+
var objFilter = condition.Filters[i];
|
|
3824
|
+
if (objFilter.Type == "Child") {
|
|
3825
|
+
RemoveFieldsFromFilters(objFilter, fields);
|
|
3826
|
+
}
|
|
3827
|
+
}
|
|
3828
|
+
}
|
|
3829
|
+
}
|
|
3830
|
+
exports.RemoveFieldsFromFilters = RemoveFieldsFromFilters;
|
|
3768
3831
|
/**
|
|
3769
3832
|
* @param Error Error object
|
|
3770
3833
|
* @param ServiceOrigin - Error Occur in Service (Service Name)
|