Open PolGuixe opened 8 years ago
I see that it also generates 2 collections:
-roles -nicoloaslopez_roles_keys
How are they used?
The roles field is published but not automatically https://github.com/nicolaslopezj/roles/blob/master/roles_server.js#L4
The roles collection is the old collection, it's a collection that is not in use right now.
nicoloaslopez_roles_keys
is a functionality that is not yet documented. It allows you to generate a key in the client and then in the server take the key and get the userId. This is only useful when using server side routes. For example: you want to download a file with permissions. First you request the key in the client, then send the user to the server side url with the key in the parameters and then you can fetch the userId with the key.
Request a key:
Roles.keys.request(Meteor.userId())
Fetch the key server side:
const key = this.request.params.key
Roles.keys.getUserId(key)
You can see a real example here
https://github.com/nicolaslopezj/orion-exporter/blob/master/exporter_client.js#L33 https://github.com/nicolaslopezj/orion-exporter/blob/master/exporter_server.js#L5
As far as I know Meteor.users just publishes
_id, profile and emails
. But with this package, I also see that theroles
field is published. Can you confirm it?