plac-micro-common 1.2.2 → 1.2.3
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.
|
@@ -13,6 +13,7 @@ exports.PermissionsGuard = void 0;
|
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
14
|
const core_1 = require("@nestjs/core");
|
|
15
15
|
const constants_1 = require("../constants");
|
|
16
|
+
const types_1 = require("../../types");
|
|
16
17
|
let PermissionsGuard = class PermissionsGuard {
|
|
17
18
|
constructor(reflector) {
|
|
18
19
|
this.reflector = reflector;
|
|
@@ -28,13 +29,16 @@ let PermissionsGuard = class PermissionsGuard {
|
|
|
28
29
|
? req.current_permissions
|
|
29
30
|
: [];
|
|
30
31
|
if (!perms.length) {
|
|
31
|
-
|
|
32
|
-
throw new common_1.UnauthorizedException("Missing permissions in request");
|
|
32
|
+
throw new common_1.UnauthorizedException("The current request does not consist of any permissions!");
|
|
33
33
|
}
|
|
34
34
|
// require ALL permissions by default
|
|
35
35
|
const hasAll = required.every((p) => perms.includes(p));
|
|
36
36
|
if (!hasAll) {
|
|
37
|
-
throw new common_1.ForbiddenException(
|
|
37
|
+
throw new common_1.ForbiddenException({
|
|
38
|
+
code: types_1.ErrorCode.PermissionDenied,
|
|
39
|
+
message: "The user does not have sufficient permissions to access this resource or perform this action!",
|
|
40
|
+
details: constants_1.REQUIRE_PERMISSIONS_KEY,
|
|
41
|
+
});
|
|
38
42
|
}
|
|
39
43
|
return true;
|
|
40
44
|
}
|
package/dist/types/http.type.js
CHANGED