-
-
Notifications
You must be signed in to change notification settings - Fork 164
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
Roles.userIsInRole returns false in onBeforeAction #61
Comments
Actually |
So based on that, it seems like an iron:router regression. I've submitted an issue there, but I'll keep this one open for now, too. |
Thanks Eric. One thing that is sorely lacking from the roles repo is an example that uses "iron:router". If you would like to contribute a simple example app, that would definitely be a big help. It would also give us a base to test with when trying out new releases.
|
@aldeed, naming the subscription is fine with me if that will solve the issue. Won't help the underlying cause of no way to wait on "null" published collections of course but that's for MDG. :-) Feel like making the change or want me to do it? |
I wonder if It will be a little while before I'd have time to submit a PR, so feel free to make the change, or I will get around to it eventually. |
Any updates? |
@jhuenges, just needs some love (ie. precious, precious time). This is still good-to-go if you'd like to submit a PR. |
I ll take a look at it next week |
This appears to be resolved now |
@rhyslbw what versions of the roles package and iron router are you using? |
@jhuenges I haven't actually tested this in isolation, and there is probably a long enough delay in my case to hide the problem. |
Thanks, I ll check it out! |
Try changing the doc's example server-side publication to:
And then client-side, in Iron Router's
That should wait for the full role list, so |
@leebenson, it still won't be correct unless this subscription is ready. So that publication should be named and the client sub handle should be exported. Yes, we could publish the roles field in a separate pub/sub, but that seems inefficient if the roles pkg is already publishing it. |
Created pull request #88 |
The pub/sub solution from @leebenson also worked for me. Thanks for it! As for an up-to-date example for usage with iron-router, that would definitely be a good think. Meteor is evolving so quickly that it is like shooting on a moving target. None of the examples here or on StackHolder worked for me. I tested with this.pause(), render() or redirect() and finally got one working with Router.go(). Hope this helps someone else:
|
Thanks @juliomac. I did add both an iron-router and flow-router example recently but they are pretty simple so I don't think they run into this problem. Happy to accept updates that make the examples more realistic. I'll be consolidating PRs and should be able to release a new version in around a month that will include Lee's PR. I'm also working on the design of roles 2.0 so if you have any requests, please open a new issue so we can discuss. |
Updated to latest iron:router and latest alanning:roles and Meteor 0.9.3, and now
Roles.userIsInRole
does not seem to work within a route'sonBeforeAction
.I can see from the console.log that the user ID is correct, but
userIsInRole
is returning false. However, after it redirects, I can enterRoles.userIsInRole(Meteor.userId(), 'admin')
in the browser console and it printstrue
.So it seems like the roles are not being correctly determined until after
onBeforeAction
runs. Possibly I need towaitOn
the subscription to theroles
field, but I don't think I had to do that before.The text was updated successfully, but these errors were encountered: