-
Notifications
You must be signed in to change notification settings - Fork 413
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
User subscription not yet ready in onBeforeAction #871
Comments
Hi @aldeed - I don't think anything has changed in the way that IR waits on subscriptions in the 0.9.4 release. Perhaps it is just a coincidence? (Which version were you one before?) IR does not wait on |
Maybe something changed in the order of things on the Meteor side, so that null subscriptions might not be ready when the routing begins. Aren't other people seeing this? It basically means you can't check security in onBeforeAction anymore. Checking whether logged in works fine because the userId is set, but the actual user doc isn't on the client yet. |
I'm not sure what iron:router I upgraded from that was working. It upgraded from Meteor 0.9.2.2 at the same time. I can't downgrade now, so I guess I'd have to create a test app to try to figure out which exact update broke things. |
I think I'm seeing the issue. I don't have a test app at the moment, I'll try and describe my scenario though. I have a onBeforeAction hook defined on most of my routes:
The route for the root URL is:
When I go to the root URL without having logged in (open in an incognito window) I just get stuck at my loading template - the hook doesn't even seem to run as I don't get any of the logging output. If I comment out the subscription to userData then it works as expected and I get sent to the login route. This is with iron:router 1.0.0.-pre3 and Meteor 0.9.3.1 |
@aldeed - you can either use |
@merrington this sounds like a different problem. Can you open another ticket with a reproduction like so: https://github.com/meteor/meteor/wiki/Contributing-to-Meteor#reporting-a-bug-in-meteor Cheers. |
It's actually @alanning's roles pkg that's publishing the roles field with a |
@aldeed I'm not sure either but I don't think it's the bump in IR version that's caused it. More likely it's the upgrade to 0.9.3 but you'd have to investigate further to say for sure. |
I'm seeing the same problem
I will try using Meteor.loggingIn() for now. Just wasn't expecting this behaviour. |
@xumx, for your case, just changing |
I made a simple app that reproduces the issue, but when I run it with various combinations of older Meteor and older iron:router, it always behaves the same. Either way, @tmeasday, my only remaining question is: How do you intend for people to potentially redirect based on a property in the user doc? I can use |
+1 for naming the subscription in Roles as @aldeed suggested. +1 for doing the same in @merrington, I'm also curious to see your repro. Once you open the new ticket please reference here. |
@aldeed - I've always used FYI: I'd avoid using |
I filed a meteor issue, so I'll close this one. |
See Meteor-Community-Packages/meteor-roles#61
Basically I'm seeing a regression with iron:router 0.9.4 and Meteor 0.9.3 where
Meteor.user()
is undefined inonBeforeAction
, so checks likeRoles.userIsInRole
always fail.EDIT: Specifically I think maybe it is no longer automatically waiting on
null
(all client) subscriptions?The text was updated successfully, but these errors were encountered: