@shophost/rest-api 2.0.15 → 2.0.17
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/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { HttpException } from "../exceptions/http-exception";
|
|
3
|
+
import { logger } from "../logging/pino";
|
|
3
4
|
export const getCurrentUser = (auth) => (headers) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4
5
|
const session = yield auth.api.getSession({
|
|
5
6
|
headers: headers,
|
|
@@ -22,13 +23,20 @@ export const isGranted = (auth) => (headers, organizationId, accessLevel) => __a
|
|
|
22
23
|
const hasPermission = yield auth.api.hasPermission({
|
|
23
24
|
headers,
|
|
24
25
|
body: {
|
|
25
|
-
organizationId
|
|
26
|
-
|
|
27
|
-
project: [accessLevel],
|
|
26
|
+
organizationId,
|
|
27
|
+
permissions: {
|
|
28
|
+
project: [accessLevel],
|
|
28
29
|
},
|
|
29
30
|
},
|
|
30
31
|
});
|
|
31
32
|
if (!hasPermission.success) {
|
|
33
|
+
logger.error({
|
|
34
|
+
organizationId,
|
|
35
|
+
accessLevel,
|
|
36
|
+
message: "User does not have permission",
|
|
37
|
+
userId: session.user.id,
|
|
38
|
+
hasPermission,
|
|
39
|
+
});
|
|
32
40
|
throw new HttpException(403, "Forbidden");
|
|
33
41
|
}
|
|
34
42
|
return session.user;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.util.js","sourceRoot":"","sources":["../../../../../../packages/rest-api/src/core/auth/auth.util.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.util.js","sourceRoot":"","sources":["../../../../../../packages/rest-api/src/core/auth/auth.util.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,M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