Meteor-Community-Packages / meteor-roles

Authorization package for Meteor, compatible with built-in accounts packages
http://meteor-community-packages.github.io/meteor-roles/
MIT License
921 stars 168 forks source link

New users missing roles in db #67

Closed isAlmogK closed 9 years ago

isAlmogK commented 9 years ago

I'm testing out the roles package, when I create a new user via meteor passwords using the accounts entry package I'm not seeing the roles in the user db object I'm also not seeing the global roles db doc.

alanning commented 9 years ago

Hi Almog, this should be logged under the accounts-entry repo. But if you can post a reproduction on github I can help you to debug.

On Wednesday, November 12, 2014, Almog Koren notifications@github.com wrote:

I'm testing out the roles package, when I create a new user via meteor passwords using the accounts entry package I'm not seeing the roles in the user db object I'm also not seeing the global roles db doc.

— Reply to this email directly or view it on GitHub https://github.com/alanning/meteor-roles/issues/67.

Adrian Lanning Co-Founder, CTO Share911 P: 203-895-8830 https://share911.com/

isAlmogK commented 9 years ago

So it's a bit wired once I call

Roles.addUsersToRoles(user._id, roleToSet);

Then it's fine

So I this was not working if (user.roles.length > 0)

I had to do this if (_.isEmpty(user.roles)) { Roles.addUsersToRoles(user._id, roleToSet); }

alanning commented 9 years ago

user.roles would not necessarily exist if the user didn't have any roles so that length check was probably throwing an error in your logs.

On Wednesday, November 12, 2014, Almog Koren notifications@github.com wrote:

So it's a bit wired once I call

Roles.addUsersToRoles(user._id, roleToSet);

Then it's fine

So I this was not working if (user.roles.length > 0)

I had to do this if (_.isEmpty(user.roles)) { Roles.addUsersToRoles(user._id, roleToSet); }

— Reply to this email directly or view it on GitHub https://github.com/alanning/meteor-roles/issues/67#issuecomment-62819497 .

isAlmogK commented 9 years ago

Yea that's what I thought, it might be good to update the docs I thought roles we're added even if the user had none I thought it was a black object.