@live-change/user-service 0.2.11 → 0.2.15

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/authenticator.js CHANGED
@@ -16,7 +16,7 @@ definition.authenticator({
16
16
  let userObserver = null
17
17
  let oldCredentials = null
18
18
  await authenticatedTable.object(session).onChange(async (authData, oldAuthData) => {
19
- output.debug("NEW USER AUTH", authData, "FROM", oldAuthData)
19
+ //output.debug("NEW USER AUTH", authData, "FROM", oldAuthData)
20
20
  const newUser = authData ? authData.user : null
21
21
  if(newUser == user) return
22
22
  if(user) {
@@ -28,7 +28,7 @@ definition.authenticator({
28
28
  }
29
29
  if(newUser) {
30
30
  user = newUser
31
- output.debug("NEW USER", user)
31
+ //output.debug("NEW USER", user)
32
32
  userObject = userTable.object(user)
33
33
  const currentUserObject = userObject
34
34
  await userObject.onChange(async (userData, oldUserData) => {
@@ -37,7 +37,7 @@ definition.authenticator({
37
37
  user,
38
38
  roles: userData.roles
39
39
  } : null
40
- output.debug("NEW CREDENTIALS", newCredentials)
40
+ //output.debug("NEW CREDENTIALS", newCredentials)
41
41
  output.change(newCredentials, oldCredentials)
42
42
  oldCredentials = newCredentials
43
43
  }).then(observer => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/user-service",
3
- "version": "0.2.11",
3
+ "version": "0.2.15",
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": "2b95c89678f276d6b3a039652169c5fc819df8df"
27
+ "gitHead": "86bc53700aca24da682d1dd414428f03cdc8d2f5"
28
28
  }
package/userItem.js CHANGED
@@ -21,7 +21,7 @@ definition.processor(function(service, app) {
21
21
  const config = model.userItem
22
22
  const writeableProperties = modelProperties || config.writableProperties
23
23
 
24
- console.log("USER ITEM", model)
24
+ //console.log("USER ITEM", model)
25
25
 
26
26
  model.itemOf = {
27
27
  what: User,
@@ -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: config.userReadAccess,
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: config.readAccess,
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: config.userReadAccess,
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