https://deepstream.io/docs/server/user-file/ is out of date
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?
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 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/
It appears
https://deepstream.io/docs/server/user-file/
is slightly outdated, please refer to
https://deepstream.io/tutorials/core/auth-file/
instead.
@yasserf Thank you, that documentation does seem better. It is working properly with serverData in users.yml and user.data in permissions.yml .
Cheers!
Awesome, happy to hear!
I'll make sure to update the other document then.
PR: https://github.com/deepstreamIO/deepstream.io-website/pull/150
Comments added
fixed (i hope)