@nocobase/acl 0.19.0-alpha.9 → 0.20.0-alpha.10
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-available-strategy.js +1 -2
- package/lib/acl.js +23 -4
- package/lib/snippet-manager.js +1 -1
- package/package.json +4 -4
|
@@ -63,11 +63,10 @@ const _ACLAvailableStrategy = class _ACLAvailableStrategy {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
matchAction(actionName) {
|
|
66
|
-
var _a;
|
|
67
66
|
if (this.options.actions == "*") {
|
|
68
67
|
return true;
|
|
69
68
|
}
|
|
70
|
-
if ((
|
|
69
|
+
if (Object.prototype.hasOwnProperty.call(this.actionsAsObject || {}, actionName)) {
|
|
71
70
|
const predicateName = this.actionsAsObject[actionName];
|
|
72
71
|
if (predicateName) {
|
|
73
72
|
return import_lodash.default.cloneDeep(predicate[predicateName]);
|
package/lib/acl.js
CHANGED
|
@@ -133,9 +133,6 @@ const _ACL = class _ACL extends import_events.default {
|
|
|
133
133
|
return null;
|
|
134
134
|
}
|
|
135
135
|
const snippetAllowed = aclRole.snippetAllowed(`${resource}:${action}`);
|
|
136
|
-
if (snippetAllowed === false) {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
136
|
const fixedParams = this.fixedParamsManager.getParams(resource, action);
|
|
140
137
|
const mergeParams = /* @__PURE__ */ __name((result) => {
|
|
141
138
|
const params = result["params"] || {};
|
|
@@ -211,7 +208,7 @@ const _ACL = class _ACL extends import_events.default {
|
|
|
211
208
|
ctx: {
|
|
212
209
|
state
|
|
213
210
|
},
|
|
214
|
-
$user:
|
|
211
|
+
$user: getUser(ctx),
|
|
215
212
|
$nRole: () => state.currentRole
|
|
216
213
|
}
|
|
217
214
|
});
|
|
@@ -315,6 +312,28 @@ const _ACL = class _ACL extends import_events.default {
|
|
|
315
312
|
};
|
|
316
313
|
__name(_ACL, "ACL");
|
|
317
314
|
let ACL = _ACL;
|
|
315
|
+
function getUser(ctx) {
|
|
316
|
+
return async ({ fields }) => {
|
|
317
|
+
var _a, _b;
|
|
318
|
+
const userFields = fields.filter((f) => f && ctx.db.getFieldByPath("users." + f));
|
|
319
|
+
(_a = ctx.logger) == null ? void 0 : _a.info("filter-parse: ", { userFields });
|
|
320
|
+
if (!ctx.state.currentUser) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
if (!userFields.length) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
const user = await ctx.db.getRepository("users").findOne({
|
|
327
|
+
filterByTk: ctx.state.currentUser.id,
|
|
328
|
+
fields: userFields
|
|
329
|
+
});
|
|
330
|
+
(_b = ctx.logger) == null ? void 0 : _b.info("filter-parse: ", {
|
|
331
|
+
$user: user == null ? void 0 : user.toJSON()
|
|
332
|
+
});
|
|
333
|
+
return user;
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
__name(getUser, "getUser");
|
|
318
337
|
// Annotate the CommonJS export names for ESM import in node:
|
|
319
338
|
0 && (module.exports = {
|
|
320
339
|
ACL
|
package/lib/snippet-manager.js
CHANGED
|
@@ -50,7 +50,7 @@ const _SnippetManager = class _SnippetManager {
|
|
|
50
50
|
snippetName = negated ? snippetName.slice(1) : snippetName;
|
|
51
51
|
const snippet = this.snippets.get(snippetName);
|
|
52
52
|
if (!snippet) {
|
|
53
|
-
|
|
53
|
+
return null;
|
|
54
54
|
}
|
|
55
55
|
const matched = snippet.actions.some((action) => (0, import_minimatch.default)(actionPath, action));
|
|
56
56
|
if (matched) {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/acl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0-alpha.10",
|
|
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.
|
|
10
|
-
"@nocobase/utils": "0.
|
|
9
|
+
"@nocobase/resourcer": "0.20.0-alpha.10",
|
|
10
|
+
"@nocobase/utils": "0.20.0-alpha.10",
|
|
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": "453e0774dae21750e96c7ddd2019c8889a0314d6"
|
|
19
19
|
}
|