@konplit-services/common 1.0.80 → 1.0.82
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.
|
@@ -8,13 +8,22 @@ exports.getAllKeys = void 0;
|
|
|
8
8
|
*/
|
|
9
9
|
const getAllKeys = (obj) => {
|
|
10
10
|
let keys = [];
|
|
11
|
-
if (typeof obj !==
|
|
11
|
+
if (typeof obj !== "object" || obj === null) {
|
|
12
12
|
return keys;
|
|
13
13
|
}
|
|
14
14
|
for (let key in obj) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
if (Array.isArray(obj[key])) {
|
|
16
|
+
// Add the array key itself
|
|
17
|
+
//TODO: UPDATE THE IMPLEMENTATION
|
|
18
|
+
// keys.push(key);
|
|
19
|
+
// Optionally, add keys of elements within the array
|
|
20
|
+
// keys = keys.concat(obj[key].flatMap((item: any) => getAllKeys(item)));
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
keys.push(key);
|
|
24
|
+
if (typeof obj[key] === "object") {
|
|
25
|
+
keys = keys.concat(getAllKeys(obj[key]));
|
|
26
|
+
}
|
|
18
27
|
}
|
|
19
28
|
}
|
|
20
29
|
return keys;
|
|
@@ -27,7 +27,7 @@ const hasPermission = (permissionCode) => {
|
|
|
27
27
|
let permissions = [];
|
|
28
28
|
const perm = yield base_1.redisWrapper.get((0, constants_1.getPermissions)(user.id));
|
|
29
29
|
if (!perm) {
|
|
30
|
-
throw new
|
|
30
|
+
throw new forbidden_error_1.ForbiddenError(language_1.lang.forbidden, error_codes_1.error_codes.INVALID_FORBIDDEN);
|
|
31
31
|
}
|
|
32
32
|
permissions = JSON.parse(perm);
|
|
33
33
|
if (!permissions.includes(permissionCode)) {
|