@live-change/user-service 0.2.11 → 0.2.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/package.json +2 -2
- package/userItem.js +8 -2
- package/userProperty.js +22 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/user-service",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"@live-change/framework": "^0.5.7",
|
|
25
25
|
"@live-change/relations-plugin": "^0.1.10"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "a0dce761d803684a74e4cf4d50c63a0dc80dd4cf"
|
|
28
28
|
}
|
package/userItem.js
CHANGED
|
@@ -32,7 +32,10 @@ definition.processor(function(service, app) {
|
|
|
32
32
|
const viewName = 'myUser' + modelName + 's'
|
|
33
33
|
service.views[viewName] = new ViewDefinition({
|
|
34
34
|
name: viewName,
|
|
35
|
-
access
|
|
35
|
+
access(params, context) {
|
|
36
|
+
if(!context.client.user) return false
|
|
37
|
+
return config.userReadAccess ? config.userReadAccess(params, context) : true
|
|
38
|
+
},
|
|
36
39
|
properties: App.rangeProperties,
|
|
37
40
|
daoPath(range, { client, context }) {
|
|
38
41
|
const path = modelRuntime().indexRangePath('byUser', [client.user], range )
|
|
@@ -44,7 +47,10 @@ definition.processor(function(service, app) {
|
|
|
44
47
|
const viewName = 'myUser' + modelName + 'sBy' + sortFieldUc
|
|
45
48
|
service.views[viewName] = new ViewDefinition({
|
|
46
49
|
name: viewName,
|
|
47
|
-
access
|
|
50
|
+
access(params, context) {
|
|
51
|
+
if(!context.client.user) return false
|
|
52
|
+
return config.userReadAccess ? config.userReadAccess(params, context) : true
|
|
53
|
+
},
|
|
48
54
|
properties: App.rangeProperties,
|
|
49
55
|
daoPath(range, { client, context }) {
|
|
50
56
|
return modelRuntime().sortedIndexRangePath('byUser' + sortFieldUc, [client.user], range )
|
package/userProperty.js
CHANGED
|
@@ -32,13 +32,34 @@ definition.processor(function(service, app) {
|
|
|
32
32
|
const viewName = 'myUser' + modelName
|
|
33
33
|
service.views[viewName] = new ViewDefinition({
|
|
34
34
|
name: viewName,
|
|
35
|
-
access
|
|
35
|
+
access(params, context) {
|
|
36
|
+
if(!context.client.user) return false
|
|
37
|
+
return config.userReadAccess ? config.userReadAccess(params, context) : true
|
|
38
|
+
},
|
|
36
39
|
daoPath(params, { client, context }) {
|
|
37
40
|
return modelRuntime().path(client.user)
|
|
38
41
|
}
|
|
39
42
|
})
|
|
40
43
|
}
|
|
41
44
|
|
|
45
|
+
if(config.userViews) {
|
|
46
|
+
for(const view of config.userViews) {
|
|
47
|
+
const viewName = view.name || ('myUser' + (view.prefix || '') + modelName + (view.suffix || ''))
|
|
48
|
+
service.views[viewName] = new ViewDefinition({
|
|
49
|
+
name: viewName,
|
|
50
|
+
access(params, context) {
|
|
51
|
+
if(!context.client.user) return false
|
|
52
|
+
return view.access ? view.access(params, context) : true
|
|
53
|
+
},
|
|
54
|
+
daoPath(params, { client, context }) {
|
|
55
|
+
return view.fields
|
|
56
|
+
? modelRuntime().limitedPath(client.user, view.fields)
|
|
57
|
+
: modelRuntime().path(client.user)
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
42
63
|
if(config.userSetAccess || config.userWriteAccess) {
|
|
43
64
|
const eventName = 'userOwned' + modelName + 'Set'
|
|
44
65
|
const actionName = 'setMyUser' + modelName
|