@nocobase/plugin-acl 1.7.10 → 1.7.12
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/dist/externalVersion.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.7.
|
|
11
|
+
"@nocobase/client": "1.7.12",
|
|
12
12
|
"antd": "5.24.2",
|
|
13
13
|
"react": "18.2.0",
|
|
14
14
|
"react-i18next": "11.18.6",
|
|
@@ -17,14 +17,14 @@ module.exports = {
|
|
|
17
17
|
"@formily/react": "2.3.0",
|
|
18
18
|
"@ant-design/icons": "5.6.1",
|
|
19
19
|
"lodash": "4.17.21",
|
|
20
|
-
"@nocobase/utils": "1.7.
|
|
21
|
-
"@nocobase/actions": "1.7.
|
|
22
|
-
"@nocobase/cache": "1.7.
|
|
23
|
-
"@nocobase/database": "1.7.
|
|
24
|
-
"@nocobase/server": "1.7.
|
|
25
|
-
"@nocobase/test": "1.7.
|
|
20
|
+
"@nocobase/utils": "1.7.12",
|
|
21
|
+
"@nocobase/actions": "1.7.12",
|
|
22
|
+
"@nocobase/cache": "1.7.12",
|
|
23
|
+
"@nocobase/database": "1.7.12",
|
|
24
|
+
"@nocobase/server": "1.7.12",
|
|
25
|
+
"@nocobase/test": "1.7.12",
|
|
26
26
|
"@formily/core": "2.3.0",
|
|
27
27
|
"@formily/antd-v5": "1.2.3",
|
|
28
28
|
"antd-style": "3.7.1",
|
|
29
|
-
"@nocobase/acl": "1.7.
|
|
29
|
+
"@nocobase/acl": "1.7.12"
|
|
30
30
|
};
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
var __create = Object.create;
|
|
10
11
|
var __defProp = Object.defineProperty;
|
|
11
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
13
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
15
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
16
|
var __export = (target, all) => {
|
|
15
17
|
for (var name in all)
|
|
@@ -23,6 +25,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
23
25
|
}
|
|
24
26
|
return to;
|
|
25
27
|
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
26
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
37
|
var setCurrentRole_exports = {};
|
|
28
38
|
__export(setCurrentRole_exports, {
|
|
@@ -31,6 +41,7 @@ __export(setCurrentRole_exports, {
|
|
|
31
41
|
module.exports = __toCommonJS(setCurrentRole_exports);
|
|
32
42
|
var import_constants = require("../constants");
|
|
33
43
|
var import_enum = require("../enum");
|
|
44
|
+
var import_lodash = __toESM(require("lodash"));
|
|
34
45
|
async function setCurrentRole(ctx, next) {
|
|
35
46
|
var _a, _b, _c;
|
|
36
47
|
let currentRole = ctx.get("X-Role");
|
|
@@ -93,9 +104,12 @@ async function setCurrentRole(ctx, next) {
|
|
|
93
104
|
}
|
|
94
105
|
}
|
|
95
106
|
if (!role) {
|
|
96
|
-
const defaultRoleModel = await cache.
|
|
107
|
+
const defaultRoleModel = await cache.wrapWithCondition(
|
|
97
108
|
`roles:${ctx.state.currentUser.id}:defaultRole`,
|
|
98
|
-
() => ctx.db.getRepository("rolesUsers").findOne({ where: { userId: ctx.state.currentUser.id, default: true } })
|
|
109
|
+
() => ctx.db.getRepository("rolesUsers").findOne({ where: { userId: ctx.state.currentUser.id, default: true } }),
|
|
110
|
+
{
|
|
111
|
+
isCacheable: (x) => !import_lodash.default.isEmpty(x)
|
|
112
|
+
}
|
|
99
113
|
);
|
|
100
114
|
role = (defaultRoleModel == null ? void 0 : defaultRoleModel.roleName) || ((_b = userRoles[0]) == null ? void 0 : _b.name);
|
|
101
115
|
}
|
|
@@ -32,14 +32,14 @@ module.exports = __toCommonJS(RoleResourceActionModel_exports);
|
|
|
32
32
|
var import_database = require("@nocobase/database");
|
|
33
33
|
class RoleResourceActionModel extends import_database.Model {
|
|
34
34
|
async writeToACL(options) {
|
|
35
|
-
const { resourceName, role } = options;
|
|
35
|
+
const { resourceName, role, transaction: transaction2 } = options;
|
|
36
36
|
const actionName = this.get("name");
|
|
37
37
|
const fields = this.get("fields");
|
|
38
38
|
const actionPath = `${resourceName}:${actionName}`;
|
|
39
39
|
const actionParams = {
|
|
40
40
|
fields
|
|
41
41
|
};
|
|
42
|
-
const scope = await this.getScope();
|
|
42
|
+
const scope = await this.getScope({ transaction: transaction2 });
|
|
43
43
|
if (scope) {
|
|
44
44
|
actionParams["own"] = scope.get("key") === "own";
|
|
45
45
|
actionParams["filter"] = scope.get("scope");
|
|
@@ -37,7 +37,7 @@ class RoleResourceModel extends import_database.Model {
|
|
|
37
37
|
role.revokeResource(resourceName);
|
|
38
38
|
}
|
|
39
39
|
async writeToACL(options) {
|
|
40
|
-
const { acl } = options;
|
|
40
|
+
const { acl, transaction } = options;
|
|
41
41
|
const resourceName = this.get("name");
|
|
42
42
|
const roleName = this.get("roleName");
|
|
43
43
|
const role = acl.getRole(roleName);
|
|
@@ -55,13 +55,14 @@ class RoleResourceModel extends import_database.Model {
|
|
|
55
55
|
});
|
|
56
56
|
role.resources.set(resourceName, resource);
|
|
57
57
|
const actions = await this.getActions({
|
|
58
|
-
transaction
|
|
58
|
+
transaction
|
|
59
59
|
});
|
|
60
60
|
for (const action of actions) {
|
|
61
61
|
await action.writeToACL({
|
|
62
62
|
acl,
|
|
63
63
|
role,
|
|
64
|
-
resourceName
|
|
64
|
+
resourceName,
|
|
65
|
+
transaction
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "权限控制",
|
|
5
5
|
"description": "Based on roles, resources, and actions, access control can precisely manage interface configuration permissions, data operation permissions, menu access permissions, and plugin permissions.",
|
|
6
6
|
"description.zh-CN": "基于角色、资源和操作的权限控制,可以精确控制界面配置权限、数据操作权限、菜单访问权限、插件权限。",
|
|
7
|
-
"version": "1.7.
|
|
7
|
+
"version": "1.7.12",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/acl",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
34
34
|
"directory": "packages/plugins/acl"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "7d8cb01842f4f426af8acd9179b88e1f0a095015"
|
|
37
37
|
}
|