Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Questions about Meteor.user().roles and package associated collections #19

Open
PolGuixe opened this issue Jun 14, 2016 · 2 comments
Open

Comments

@PolGuixe
Copy link

PolGuixe commented Jun 14, 2016

As far as I know Meteor.users just publishes _id, profile and emails. But with this package, I also see that the roles field is published. Can you confirm it?

@PolGuixe
Copy link
Author

I see that it also generates 2 collections:

-roles
-nicoloaslopez_roles_keys

How are they used?

@PolGuixe PolGuixe changed the title Question: does this package makes user.roles available in the client when user is logged in? Questions about Meteor.user().roles and package associated collections Jun 14, 2016
@nicolaslopezj
Copy link
Owner

nicolaslopezj commented Jun 17, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants