How Can I Prevent Meteor.user()'s Timing Hole?
A template requests... if (this.userRequesting._id === Meteor.user()._id) { ... } ...to check for a person's identity. (I suspect this isn't the best way to handle this, but I'll
Solution 1:
Yep, you've basically gotten it right. When you first refresh the page, the user isn't consider to be logged in, and it has to verify that it is. But the template stuff is called immediately, and then again when other stuff is loaded (if you put an alert
in a rendered
method, you'll notice that). The best solution is exactly what you suggested, although you can use Meteor.userId()
to get just the id:
if (Meteor.userId() && Meteor.userId() === this.userRequesting._id) {
// ...
Solution 2:
You can use Meteor.userId()
to get the _id
attribute of the signed in user or null
(I think) if the user is not signed in.
Post a Comment for "How Can I Prevent Meteor.user()'s Timing Hole?"