deepstream.io icon indicating copy to clipboard operation
deepstream.io copied to clipboard

https://deepstream.io/docs/server/user-file/ is out of date

Open reactor81 opened this issue 9 years ago • 8 comments

I've been able to setup a working users.json file, and the password is working, and I can use user.id in my permissions.yaml.

However user.data always seems to be null, so I get an auth error:

MESSAGE_PERMISSION_ERROR | error when executing function anonymous(_,user,data,oldData,now,action
/**/) {
return user.clientData.role === 'admin';
}
for [object Object]: TypeError: Cannot read property 'role' of undefined

My users.json (I also tried a users.yml with same settings, but that also did not work) looks like:

{
    "myadminname": {
        "password": "mypass",
        "data": { "role": "admin" },
    },
    "user": {
        "password": "myuserpass",
        "data": { "role": "user" },
    }
}

Same with a yaml version as below:

myusername:
  password: "mypass"
  data:
    role: admin
user:
  password: "myuserpass"
  data:
    role: user

Any ideas on why this error might be happening?

reactor81 avatar Jul 02 '17 02:07 reactor81

I believe your user data has to be:

clientData:
 # data to be send to client on connect
serverData:
 # data not to leave the server, maps onto valve rules

https://deepstream.io/tutorials/core/permission-conf-advanced/#variables

Can you link me to where you got your example? Thanks!

yasserf avatar Jul 02 '17 08:07 yasserf

@yasserf Thanks for your reply. clientData in the yaml/json also returns null for user.data or user.clientData in the permissions yml.

I found examples of user.data below:

https://deepstream.io/docs/server/user-file/user-file.html

https://deepstream.io/docs/server/valve-permissions/

reactor81 avatar Jul 02 '17 08:07 reactor81

It appears

https://deepstream.io/docs/server/user-file/

is slightly outdated, please refer to

https://deepstream.io/tutorials/core/auth-file/

instead.

yasserf avatar Jul 02 '17 08:07 yasserf

@yasserf Thank you, that documentation does seem better. It is working properly with serverData in users.yml and user.data in permissions.yml .

Cheers!

reactor81 avatar Jul 02 '17 08:07 reactor81

Awesome, happy to hear!

I'll make sure to update the other document then.

yasserf avatar Jul 02 '17 08:07 yasserf

PR: https://github.com/deepstreamIO/deepstream.io-website/pull/150

mrby avatar Jul 03 '17 14:07 mrby

Comments added

yasserf avatar Jul 03 '17 16:07 yasserf

fixed (i hope)

mrby avatar Jul 03 '17 16:07 mrby