@steedos/standard-permission 3.0.0-beta.23 → 3.0.0-beta.25
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/standard-permission",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.25",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"description": "steedos package",
|
|
13
13
|
"repository": {},
|
|
14
14
|
"license": "MIT",
|
|
15
|
-
"gitHead": "
|
|
15
|
+
"gitHead": "bcc2f288c4444202c4ec728beed73d00fe429841",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"clone": "^2.1.2"
|
|
18
18
|
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
const objectql = require('@steedos/objectql');
|
|
2
|
-
|
|
3
|
-
Creator.Objects['permission_shares'].triggers = Object.assign({}, Creator.Objects['permission_shares'].triggers, {
|
|
4
|
-
"before.insert.server.sharing": {
|
|
5
|
-
on: "server",
|
|
6
|
-
when: "before.insert",
|
|
7
|
-
todo: function (userId, doc) {
|
|
8
|
-
if (_.isEmpty(doc.organizations) && _.isEmpty(doc.users)) {
|
|
9
|
-
throw new Meteor.Error(500, "请在授权组织或授权用户中至少填写一个值");
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"before.update.server.sharing": {
|
|
14
|
-
on: "server",
|
|
15
|
-
when: "before.update",
|
|
16
|
-
todo: function (userId, doc, fieldNames, modifier, options) {
|
|
17
|
-
var errMsg;
|
|
18
|
-
errMsg = t("creator_permission_share_miss");
|
|
19
|
-
if (fieldNames.length === 1) {
|
|
20
|
-
if (fieldNames.indexOf("organizations") > -1) {
|
|
21
|
-
if (_.isEmpty(modifier.$set.organizations) && _.isEmpty(doc.users)) {
|
|
22
|
-
throw new Meteor.Error(500, errMsg);
|
|
23
|
-
}
|
|
24
|
-
} else if (fieldNames.indexOf("users") > -1) {
|
|
25
|
-
if (_.isEmpty(doc.organizations) && _.isEmpty(modifier.$set.users)) {
|
|
26
|
-
throw new Meteor.Error(500, errMsg);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
} else if (_.isEmpty(modifier.$set.organizations) && _.isEmpty(modifier.$set.users)) {
|
|
30
|
-
throw new Meteor.Error(500, errMsg);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
if(Meteor.isServer){
|
|
37
|
-
Meteor.startup(function() {
|
|
38
|
-
let objectName = 'permission_shares';
|
|
39
|
-
Creator.getCollection(objectName).find({}, {
|
|
40
|
-
fields: {
|
|
41
|
-
_id: 1,
|
|
42
|
-
object_name: 1,
|
|
43
|
-
filters: 1
|
|
44
|
-
}
|
|
45
|
-
}).observe({
|
|
46
|
-
added: function(doc){
|
|
47
|
-
objectql.addConfig(objectName, doc)
|
|
48
|
-
},
|
|
49
|
-
changed: function(doc){
|
|
50
|
-
objectql.addConfig(objectName, doc)
|
|
51
|
-
},
|
|
52
|
-
removed: function(doc){
|
|
53
|
-
objectql.removeConfig(objectName, doc)
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
});
|
|
57
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
var _ = require("underscore");
|
|
2
|
-
function checkType(name, type){
|
|
3
|
-
if(_.include(['admin','user','supplier','customer'], name) && type != 'profile'){
|
|
4
|
-
throw new Meteor.Error(500, "API名称为admin,user,supplier,customer时,类别必须为简档");
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
Creator.Objects['permission_set'].triggers = Object.assign({}, Creator.Objects['permission_set'].triggers,{
|
|
9
|
-
"before.insert.server.check": {
|
|
10
|
-
on: "server",
|
|
11
|
-
when: "before.insert",
|
|
12
|
-
todo: function (userId, doc) {
|
|
13
|
-
var newName;
|
|
14
|
-
// console.log "before.insert.server.check,doc:", doc
|
|
15
|
-
newName = doc != null ? doc.name : void 0;
|
|
16
|
-
if (newName && Creator.getCollection("permission_set").findOne({
|
|
17
|
-
space: doc.space,
|
|
18
|
-
name: newName
|
|
19
|
-
}, {
|
|
20
|
-
fields: {
|
|
21
|
-
name: 1
|
|
22
|
-
}
|
|
23
|
-
})) {
|
|
24
|
-
throw new Meteor.Error(500, "API名称不能重复");
|
|
25
|
-
}
|
|
26
|
-
checkType(doc.name, doc.type);
|
|
27
|
-
if(doc.type === 'profile'){
|
|
28
|
-
if(!doc.license){
|
|
29
|
-
// throw new Meteor.Error(500, "请指定许可证");
|
|
30
|
-
}else{
|
|
31
|
-
// if(_.indexOf(_.pluck(Steedos.getLicenseOptionsSync(doc.space), 'value'), doc.license) < 0){
|
|
32
|
-
// throw new Meteor.Error(500, "无效的许可证");
|
|
33
|
-
// }
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// if(doc.license){
|
|
38
|
-
// if(_.indexOf(_.pluck(Steedos.getLicenseOptionsSync(doc.space), 'value'), doc.license) < 0){
|
|
39
|
-
// throw new Meteor.Error(500, "无效的许可证");
|
|
40
|
-
// }
|
|
41
|
-
// }
|
|
42
|
-
|
|
43
|
-
if(doc.type === 'profile'){
|
|
44
|
-
delete doc.users
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
"before.update.server.check": {
|
|
49
|
-
on: "server",
|
|
50
|
-
when: "before.update",
|
|
51
|
-
todo: function (userId, doc, fieldNames, modifier, options) {
|
|
52
|
-
var newName, ref;
|
|
53
|
-
newName = (ref = modifier.$set) != null ? ref.name : void 0;
|
|
54
|
-
if (newName && Creator.getCollection("permission_set").findOne({
|
|
55
|
-
space: doc.space,
|
|
56
|
-
name: newName,
|
|
57
|
-
_id: {
|
|
58
|
-
$ne: doc._id
|
|
59
|
-
}
|
|
60
|
-
}, {
|
|
61
|
-
fields: {
|
|
62
|
-
name: 1
|
|
63
|
-
}
|
|
64
|
-
})) {
|
|
65
|
-
throw new Meteor.Error(500, "API名称不能重复");
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
var set = modifier.$set || {}
|
|
69
|
-
if(_.has(set, 'name') || _.has(set, 'type')){
|
|
70
|
-
checkType(set.name || doc.name, set.type || doc.type);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if(_.has(set, 'type') || _.has(set, 'users')){
|
|
74
|
-
var type = set.type || doc.type;
|
|
75
|
-
var users = set.users || doc.users
|
|
76
|
-
if(type === 'profile'){
|
|
77
|
-
if(_.has(set, 'users')){
|
|
78
|
-
modifier.$set.users = []
|
|
79
|
-
}else{
|
|
80
|
-
if(!modifier.$unset){
|
|
81
|
-
modifier.$unset = {}
|
|
82
|
-
}
|
|
83
|
-
modifier.$unset.users = 1
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
var unset = modifier.$unset || {}
|
|
88
|
-
if((_.has(set, 'license') && set.license != doc.license)){
|
|
89
|
-
throw new Meteor.Error(500, '禁止修改许可证');
|
|
90
|
-
// let _type = set.type || doc.type;
|
|
91
|
-
// if(_type === 'profile'){
|
|
92
|
-
// if(!set.license){
|
|
93
|
-
// throw new Meteor.Error(500, "请指定许可证");
|
|
94
|
-
// }else{
|
|
95
|
-
|
|
96
|
-
// if(_.indexOf(_.pluck(Steedos.getLicenseOptionsSync(doc.space), 'value'), set.license) < 0){
|
|
97
|
-
// throw new Meteor.Error(500, "无效的许可证");
|
|
98
|
-
// }
|
|
99
|
-
// }
|
|
100
|
-
// }
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
"after.update.server.syncSpaceUserProfile": {
|
|
105
|
-
on: "server",
|
|
106
|
-
when: "after.update",
|
|
107
|
-
todo: function(userId, doc, fieldNames, modifier, options){
|
|
108
|
-
modifier.$set = modifier.$set || {}
|
|
109
|
-
if(doc.type === 'profile' && _.has(modifier.$set, 'name') && modifier.$set.name != this.previous.name){
|
|
110
|
-
if(doc.space){
|
|
111
|
-
db.space_users.update({space: doc.space, profile: this.previous.name}, {$set: {profile: doc.name}}, {
|
|
112
|
-
multi: true
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
"before.remove.server.check": {
|
|
119
|
-
on: "server",
|
|
120
|
-
when: "before.remove",
|
|
121
|
-
todo: function (userId, doc) {
|
|
122
|
-
var documents, object_collections;
|
|
123
|
-
console.log('permission_objects', {permission_set_id: doc._id, space: doc.space});
|
|
124
|
-
var pero= Creator.getCollection("permission_objects").find({permission_set_id: doc._id, space: doc.space}, {fields:{_id:1}});
|
|
125
|
-
if (pero.count() > 0) {
|
|
126
|
-
throw new Meteor.Error(500, `此记录已在对象权限中引用`);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
})
|