@nocobase/plugin-acl 0.7.0-alpha.82 → 0.7.1-alpha.4
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/model/RoleResourceActionModel.js +6 -0
- package/lib/model/RoleResourceModel.d.ts +1 -1
- package/lib/model/RoleResourceModel.js +13 -7
- package/lib/server.js +3 -1
- package/package.json +5 -5
- package/src/model/RoleResourceActionModel.ts +6 -0
- package/src/model/RoleResourceModel.ts +7 -2
- package/src/server.ts +3 -1
|
@@ -72,6 +72,12 @@ class RoleResourceActionModel extends _database().Model {
|
|
|
72
72
|
|
|
73
73
|
const field = _step.value;
|
|
74
74
|
const collectionField = collection.getField(field);
|
|
75
|
+
|
|
76
|
+
if (!collectionField) {
|
|
77
|
+
console.log(`${field} does not exist`);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
|
|
75
81
|
const fieldType = collectionField.get('interface');
|
|
76
82
|
const fieldActions = associationFieldsActions === null || associationFieldsActions === void 0 ? void 0 : (_associationFieldsAct = associationFieldsActions[fieldType]) === null || _associationFieldsAct === void 0 ? void 0 : _associationFieldsAct[availableAction];
|
|
77
83
|
const fieldTarget = collectionField.get('target');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Model } from '@nocobase/database';
|
|
2
1
|
import { ACL, ACLRole } from '@nocobase/acl';
|
|
2
|
+
import { Model } from '@nocobase/database';
|
|
3
3
|
import { AssociationFieldsActions, GrantHelper } from '../server';
|
|
4
4
|
export declare class RoleResourceModel extends Model {
|
|
5
5
|
revoke(options: {
|
|
@@ -5,20 +5,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.RoleResourceModel = void 0;
|
|
7
7
|
|
|
8
|
-
function
|
|
9
|
-
const data = require("@nocobase/
|
|
8
|
+
function _acl() {
|
|
9
|
+
const data = require("@nocobase/acl");
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
_acl = function _acl() {
|
|
12
12
|
return data;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
return data;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function
|
|
19
|
-
const data = require("@nocobase/
|
|
18
|
+
function _database() {
|
|
19
|
+
const data = require("@nocobase/database");
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
_database = function _database() {
|
|
22
22
|
return data;
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -79,7 +79,13 @@ class RoleResourceModel extends _database().Model {
|
|
|
79
79
|
|
|
80
80
|
const roleName = _this.get('roleName');
|
|
81
81
|
|
|
82
|
-
const role = acl.getRole(roleName);
|
|
82
|
+
const role = acl.getRole(roleName);
|
|
83
|
+
|
|
84
|
+
if (!role) {
|
|
85
|
+
console.log(`${roleName} role does not exist`);
|
|
86
|
+
return;
|
|
87
|
+
} // revoke resource of role
|
|
88
|
+
|
|
83
89
|
|
|
84
90
|
yield _this.revoke({
|
|
85
91
|
role,
|
package/lib/server.js
CHANGED
|
@@ -286,7 +286,9 @@ class PluginACL extends _server().Plugin {
|
|
|
286
286
|
var _ref4 = _asyncToGenerator(function* (model, options) {
|
|
287
287
|
const role = _this4.acl.getRole(model.get('roleName'));
|
|
288
288
|
|
|
289
|
-
role
|
|
289
|
+
if (role) {
|
|
290
|
+
role.revokeResource(model.get('name'));
|
|
291
|
+
}
|
|
290
292
|
});
|
|
291
293
|
|
|
292
294
|
return function (_x7, _x8) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-acl",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1-alpha.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"licenses": [
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
"main": "./lib/index.js",
|
|
13
13
|
"types": "./lib/index.d.ts",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@nocobase/acl": "0.7.
|
|
16
|
-
"@nocobase/database": "0.7.
|
|
17
|
-
"@nocobase/server": "0.7.
|
|
15
|
+
"@nocobase/acl": "0.7.1-alpha.4",
|
|
16
|
+
"@nocobase/database": "0.7.1-alpha.4",
|
|
17
|
+
"@nocobase/server": "0.7.1-alpha.4"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
21
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
22
22
|
"directory": "packages/plugins/acl"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "570d039f1904a041729c1967c0637b1109c278a8"
|
|
25
25
|
}
|
|
@@ -44,6 +44,12 @@ export class RoleResourceActionModel extends Model {
|
|
|
44
44
|
|
|
45
45
|
for (const field of fields) {
|
|
46
46
|
const collectionField = collection.getField(field);
|
|
47
|
+
|
|
48
|
+
if (!collectionField) {
|
|
49
|
+
console.log(`${field} does not exist`);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
|
|
47
53
|
const fieldType = collectionField.get('interface') as string;
|
|
48
54
|
|
|
49
55
|
const fieldActions: AssociationFieldAction = associationFieldsActions?.[fieldType]?.[availableAction];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Database, Model } from '@nocobase/database';
|
|
2
1
|
import { ACL, ACLResource, ACLRole } from '@nocobase/acl';
|
|
3
|
-
import {
|
|
2
|
+
import { Model } from '@nocobase/database';
|
|
4
3
|
import { AssociationFieldsActions, GrantHelper } from '../server';
|
|
4
|
+
import { RoleResourceActionModel } from './RoleResourceActionModel';
|
|
5
5
|
|
|
6
6
|
export class RoleResourceModel extends Model {
|
|
7
7
|
async revoke(options: { role: ACLRole; resourceName: string; grantHelper: GrantHelper }) {
|
|
@@ -36,6 +36,11 @@ export class RoleResourceModel extends Model {
|
|
|
36
36
|
const roleName = this.get('roleName') as string;
|
|
37
37
|
const role = acl.getRole(roleName);
|
|
38
38
|
|
|
39
|
+
if (!role) {
|
|
40
|
+
console.log(`${roleName} role does not exist`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
39
44
|
// revoke resource of role
|
|
40
45
|
await this.revoke({ role, resourceName, grantHelper });
|
|
41
46
|
|
package/src/server.ts
CHANGED
|
@@ -180,7 +180,9 @@ export class PluginACL extends Plugin {
|
|
|
180
180
|
|
|
181
181
|
this.app.db.on('rolesResources.afterDestroy', async (model, options) => {
|
|
182
182
|
const role = this.acl.getRole(model.get('roleName'));
|
|
183
|
-
role
|
|
183
|
+
if (role) {
|
|
184
|
+
role.revokeResource(model.get('name'));
|
|
185
|
+
}
|
|
184
186
|
});
|
|
185
187
|
|
|
186
188
|
this.app.db.on('collections.afterDestroy', async (model, options) => {
|