@live-change/user-service 0.8.15 → 0.8.17
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 +13 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/user-service",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.17",
|
|
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.8.
|
|
26
|
-
"@live-change/relations-plugin": "^0.8.
|
|
25
|
+
"@live-change/framework": "^0.8.17",
|
|
26
|
+
"@live-change/relations-plugin": "^0.8.17",
|
|
27
27
|
"pluralize": "^8.0.0"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "a736d9be9e93757a967867b98b840e08de2d713c"
|
|
30
30
|
}
|
package/sessionOrUserItem.js
CHANGED
|
@@ -139,7 +139,7 @@ definition.processor(function(service, app) {
|
|
|
139
139
|
lte: '_'+ params[propertyName]
|
|
140
140
|
}
|
|
141
141
|
const path = modelRuntime().indexObjectPath('bySessionOrUser', owner, range )
|
|
142
|
-
//console.log("DAO PATH", path, "range", range, 'params', params)
|
|
142
|
+
//console.log("DAO PATH", path, "range", range, 'params', params, 'result', await app.dao.get(path))
|
|
143
143
|
return path
|
|
144
144
|
}
|
|
145
145
|
})
|
|
@@ -171,7 +171,7 @@ definition.processor(function(service, app) {
|
|
|
171
171
|
properties: App.rangeProperties,
|
|
172
172
|
daoPath(range, { client, context }) {
|
|
173
173
|
const owner = client.user ? ['user_User', client.user] : ['session_Session', client.session]
|
|
174
|
-
return modelRuntime().sortedIndexRangePath('
|
|
174
|
+
return modelRuntime().sortedIndexRangePath('bySessionOrUser' + sortFieldUc, owner, App.extractRange(range))
|
|
175
175
|
}
|
|
176
176
|
})
|
|
177
177
|
}
|
|
@@ -232,11 +232,11 @@ definition.processor(function(service, app) {
|
|
|
232
232
|
async execute(properties, { client, service }, emit) {
|
|
233
233
|
const entity = await modelRuntime().get(properties[modelPropertyName])
|
|
234
234
|
if(!entity) throw 'not_found'
|
|
235
|
-
if(entity.sessionOrUserType
|
|
236
|
-
if(entity.sessionOrUser
|
|
235
|
+
if(entity.sessionOrUserType === 'user_User') {
|
|
236
|
+
if(entity.sessionOrUser !== client.user) throw 'not_authorized'
|
|
237
237
|
}
|
|
238
|
-
if(entity.sessionOrUserType
|
|
239
|
-
if(entity.sessionOrUser
|
|
238
|
+
if(entity.sessionOrUserType === 'session_Session') {
|
|
239
|
+
if(entity.sessionOrUser !== client.session) throw 'not_authorized'
|
|
240
240
|
}
|
|
241
241
|
let updateObject = {}
|
|
242
242
|
for(const propertyName of writeableProperties) {
|
|
@@ -244,7 +244,9 @@ definition.processor(function(service, app) {
|
|
|
244
244
|
updateObject[propertyName] = properties[propertyName]
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
const merged = App.utils.mergeDeep({},
|
|
247
|
+
const merged = App.utils.mergeDeep({ [modelPropertyName]: properties[modelPropertyName] },
|
|
248
|
+
entity, updateObject)
|
|
249
|
+
|
|
248
250
|
await App.validation.validate(merged, validators, { source: action, action, service, app, client })
|
|
249
251
|
const identifiers = client.user ? {
|
|
250
252
|
sessionOrUserType: 'user_User',
|
|
@@ -281,11 +283,11 @@ definition.processor(function(service, app) {
|
|
|
281
283
|
async execute(properties, { client, service }, emit) {
|
|
282
284
|
const entity = await modelRuntime().get(properties[modelPropertyName])
|
|
283
285
|
if(!entity) throw 'not_found'
|
|
284
|
-
if(entity.sessionOrUserType
|
|
285
|
-
if(entity.sessionOrUser
|
|
286
|
+
if(entity.sessionOrUserType === 'user_User') {
|
|
287
|
+
if(entity.sessionOrUser !== client.user) throw 'not_authorized'
|
|
286
288
|
}
|
|
287
|
-
if(entity.sessionOrUserType
|
|
288
|
-
if(entity.sessionOrUser
|
|
289
|
+
if(entity.sessionOrUserType === 'session_Session') {
|
|
290
|
+
if(entity.sessionOrUser !== client.session) throw 'not_authorized'
|
|
289
291
|
}
|
|
290
292
|
const identifiers = client.user ? {
|
|
291
293
|
sessionOrUserType: 'user_User',
|