var user = Meteor.user();
if (!user.emails[0].verified) {
// warning message
}
But this code sometimes return in console:Cannot read property ‘emails’ of undefined
And sometimes not. The field in collection is exists and have a value.
What is the right way to retrieve status of email?
It’s because the Meteor.users collection takes a bit to load, and so it depends on chance whether Meteor.user() will return the user or not (client-side).
Hints towards possible solutions: iron:router’s waitOn(), meteorhacks:fast-render with custom publication for current user record & subscription and injection into all routes, or rerunning checks reactively and just checking if the user is available yet or not, and doing nothing if it’s not, because on the next reactive rerun it will be available.
This is definitely something that bites lots of people initially. Quite unexpected.