@nocobase/acl 2.0.0-alpha.5 → 2.0.0-alpha.50
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/lib/acl.js +5 -2
- package/package.json +4 -4
package/lib/acl.js
CHANGED
|
@@ -297,6 +297,7 @@ const _ACL = class _ACL extends import_events.default {
|
|
|
297
297
|
middleware() {
|
|
298
298
|
const acl = this;
|
|
299
299
|
return /* @__PURE__ */ __name(async function ACLMiddleware(ctx, next) {
|
|
300
|
+
ctx.acl = acl;
|
|
300
301
|
const roleName = ctx.state.currentRole || "anonymous";
|
|
301
302
|
const { resourceName: rawResourceName, actionName } = ctx.action;
|
|
302
303
|
let resourceName = rawResourceName;
|
|
@@ -464,9 +465,11 @@ const _ACL = class _ACL extends import_events.default {
|
|
|
464
465
|
__name(_ACL, "ACL");
|
|
465
466
|
let ACL = _ACL;
|
|
466
467
|
function getUser(ctx) {
|
|
468
|
+
const dataSource = ctx.app.dataSourceManager.dataSources.get("main");
|
|
469
|
+
const db = dataSource.collectionManager.db;
|
|
467
470
|
return async ({ fields }) => {
|
|
468
471
|
var _a, _b;
|
|
469
|
-
const userFields = fields.filter((f) => f &&
|
|
472
|
+
const userFields = fields.filter((f) => f && db.getFieldByPath("users." + f));
|
|
470
473
|
(_a = ctx.logger) == null ? void 0 : _a.info("filter-parse: ", { userFields });
|
|
471
474
|
if (!ctx.state.currentUser) {
|
|
472
475
|
return;
|
|
@@ -474,7 +477,7 @@ function getUser(ctx) {
|
|
|
474
477
|
if (!userFields.length) {
|
|
475
478
|
return;
|
|
476
479
|
}
|
|
477
|
-
const user = await
|
|
480
|
+
const user = await db.getRepository("users").findOne({
|
|
478
481
|
filterByTk: ctx.state.currentUser.id,
|
|
479
482
|
fields: userFields
|
|
480
483
|
});
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/acl",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.50",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/resourcer": "2.0.0-alpha.
|
|
10
|
-
"@nocobase/utils": "2.0.0-alpha.
|
|
9
|
+
"@nocobase/resourcer": "2.0.0-alpha.50",
|
|
10
|
+
"@nocobase/utils": "2.0.0-alpha.50",
|
|
11
11
|
"minimatch": "^5.1.1"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
16
16
|
"directory": "packages/acl"
|
|
17
17
|
},
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "a6eb64abf3632e116ad0b295a7f410270a1059d1"
|
|
19
19
|
}
|