@live-change/user-service 0.9.58 → 0.9.60
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 +4 -4
- package/sessionOrUserItem.js +22 -0
- package/userItem.js +21 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/user-service",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.60",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@live-change/framework": "^0.9.
|
|
26
|
-
"@live-change/relations-plugin": "^0.9.
|
|
25
|
+
"@live-change/framework": "^0.9.60",
|
|
26
|
+
"@live-change/relations-plugin": "^0.9.60",
|
|
27
27
|
"pluralize": "^8.0.0"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "8420ad3852216027b648c31f3c908a7b5e6f4292"
|
|
30
30
|
}
|
package/sessionOrUserItem.js
CHANGED
|
@@ -176,6 +176,28 @@ definition.processor(function(service, app) {
|
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
if(config.ownerReadAccess) {
|
|
180
|
+
const viewName = 'my' + modelName
|
|
181
|
+
service.views[viewName] = new ViewDefinition({
|
|
182
|
+
name: viewName,
|
|
183
|
+
async access(params, context) {
|
|
184
|
+
if(context.visibilityTest) return true
|
|
185
|
+
const data = await modelRuntime().get(params[modelPropertyName])
|
|
186
|
+
if (data.sessionOrUserType === 'user_User') {
|
|
187
|
+
if (data.sessionOrUser !== context.client.user) return false
|
|
188
|
+
} else if (data.sessionOrUserType === 'session_Session') {
|
|
189
|
+
if (data.sessionOrUser !== context.client.session) return false
|
|
190
|
+
}
|
|
191
|
+
return config.userReadAccess ? config.userReadAccess(params, context) : true
|
|
192
|
+
},
|
|
193
|
+
properties: App.rangeProperties,
|
|
194
|
+
daoPath(params, { client, context }) {
|
|
195
|
+
const path = modelRuntime().path(params[modelPropertyName])
|
|
196
|
+
return path
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
}
|
|
200
|
+
|
|
179
201
|
if(config.ownerCreateAccess || config.ownerWriteAccess) {
|
|
180
202
|
const eventName = modelName + 'Created'
|
|
181
203
|
const actionName = 'createMy' + modelName
|
package/userItem.js
CHANGED
|
@@ -53,6 +53,7 @@ definition.processor(function(service, app) {
|
|
|
53
53
|
name: viewName,
|
|
54
54
|
access(params, context) {
|
|
55
55
|
if(!context.client.user) return false
|
|
56
|
+
if(context.visibilityTest) return true
|
|
56
57
|
return config.userReadAccess ? config.userReadAccess(params, context) : true
|
|
57
58
|
},
|
|
58
59
|
properties: App.rangeProperties,
|
|
@@ -60,7 +61,26 @@ definition.processor(function(service, app) {
|
|
|
60
61
|
return modelRuntime().sortedIndexRangePath('byUser' + sortFieldUc, [client.user], range )
|
|
61
62
|
}
|
|
62
63
|
})
|
|
63
|
-
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if(config.userReadAccess) {
|
|
68
|
+
const viewName = 'myUser' + modelName
|
|
69
|
+
service.views[viewName] = new ViewDefinition({
|
|
70
|
+
name: viewName,
|
|
71
|
+
async access(params, context) {
|
|
72
|
+
if(!context.client.user) return false
|
|
73
|
+
if(context.visibilityTest) return true
|
|
74
|
+
const data = await modelRuntime().get(params[modelPropertyName])
|
|
75
|
+
if(data.user !== context.client.user) return false
|
|
76
|
+
return config.userReadAccess ? config.userReadAccess(params, context) : true
|
|
77
|
+
},
|
|
78
|
+
properties: App.rangeProperties,
|
|
79
|
+
daoPath(params, { client, context }) {
|
|
80
|
+
const path = modelRuntime().path(params[modelPropertyName])
|
|
81
|
+
return path
|
|
82
|
+
}
|
|
83
|
+
})
|
|
64
84
|
}
|
|
65
85
|
|
|
66
86
|
if(config.userCreateAccess || config.userWriteAccess) {
|