@nocobase/acl 0.20.0-alpha.5 → 0.20.0-alpha.6
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 +23 -1
- package/package.json +4 -4
package/lib/acl.js
CHANGED
|
@@ -211,7 +211,7 @@ const _ACL = class _ACL extends import_events.default {
|
|
|
211
211
|
ctx: {
|
|
212
212
|
state
|
|
213
213
|
},
|
|
214
|
-
$user:
|
|
214
|
+
$user: getUser(ctx),
|
|
215
215
|
$nRole: () => state.currentRole
|
|
216
216
|
}
|
|
217
217
|
});
|
|
@@ -315,6 +315,28 @@ const _ACL = class _ACL extends import_events.default {
|
|
|
315
315
|
};
|
|
316
316
|
__name(_ACL, "ACL");
|
|
317
317
|
let ACL = _ACL;
|
|
318
|
+
function getUser(ctx) {
|
|
319
|
+
return async ({ fields }) => {
|
|
320
|
+
var _a, _b;
|
|
321
|
+
const userFields = fields.filter((f) => f && ctx.db.getFieldByPath("users." + f));
|
|
322
|
+
(_a = ctx.logger) == null ? void 0 : _a.info("filter-parse: ", { userFields });
|
|
323
|
+
if (!ctx.state.currentUser) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
if (!userFields.length) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
const user = await ctx.db.getRepository("users").findOne({
|
|
330
|
+
filterByTk: ctx.state.currentUser.id,
|
|
331
|
+
fields: userFields
|
|
332
|
+
});
|
|
333
|
+
(_b = ctx.logger) == null ? void 0 : _b.info("filter-parse: ", {
|
|
334
|
+
$user: user == null ? void 0 : user.toJSON()
|
|
335
|
+
});
|
|
336
|
+
return user;
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
__name(getUser, "getUser");
|
|
318
340
|
// Annotate the CommonJS export names for ESM import in node:
|
|
319
341
|
0 && (module.exports = {
|
|
320
342
|
ACL
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/acl",
|
|
3
|
-
"version": "0.20.0-alpha.
|
|
3
|
+
"version": "0.20.0-alpha.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/resourcer": "0.20.0-alpha.
|
|
10
|
-
"@nocobase/utils": "0.20.0-alpha.
|
|
9
|
+
"@nocobase/resourcer": "0.20.0-alpha.6",
|
|
10
|
+
"@nocobase/utils": "0.20.0-alpha.6",
|
|
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": "281767b02ce11f9172fb72e5e53ff98bc80b6eaf"
|
|
19
19
|
}
|