@konplit-services/common 1.0.314 → 1.0.315
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.
|
@@ -24,26 +24,22 @@ const hasPermission = (userType, permissionCode) => {
|
|
|
24
24
|
}
|
|
25
25
|
const user = req.currentUser;
|
|
26
26
|
if (userType !== user.userType) {
|
|
27
|
-
console.log("user types", userType, user.userType);
|
|
28
27
|
throw new forbidden_error_1.ForbiddenError(language_1.lang.forbidden, error_codes_1.error_codes.INVALID_FORBIDDEN);
|
|
29
28
|
}
|
|
30
29
|
try {
|
|
31
30
|
let permissions = [];
|
|
32
31
|
const perm = yield base_1.redisWrapper.get((0, constants_1.getPermissions)(user.id));
|
|
33
32
|
if (!perm) {
|
|
34
|
-
console.log("no permis", perm);
|
|
35
33
|
throw new forbidden_error_1.ForbiddenError(language_1.lang.forbidden, error_codes_1.error_codes.INVALID_FORBIDDEN);
|
|
36
34
|
}
|
|
37
35
|
permissions = JSON.parse(perm);
|
|
38
36
|
if (!permissions.includes(permissionCode)) {
|
|
39
|
-
console.log("permission", permissionCode);
|
|
40
37
|
throw new forbidden_error_1.ForbiddenError(language_1.lang.forbidden, error_codes_1.error_codes.INVALID_FORBIDDEN);
|
|
41
38
|
}
|
|
42
39
|
return next();
|
|
43
40
|
}
|
|
44
41
|
catch (error) {
|
|
45
42
|
console.log();
|
|
46
|
-
console.log("error log", error);
|
|
47
43
|
throw error;
|
|
48
44
|
}
|
|
49
45
|
});
|