I need to find out whether the user who triggers a click. event
has a verified email. In case "true" he should be redirected to another page, where he can call a server side method. In case "false" he should be redirected to a page, where he can click a button to resent a new verification link to him.
I tried to use some functions I found in other questions, but it didn´t work. Here is my code for the click. event and if function which does not work out:
"click. event": function(e){
e.preventDefault();
if (this.userId && Meteor.user().emails[0].verified)
{
Router.go('LinkToCallTheMethod');
}; else
{
console.log('Please verify email first');
Router.go('LinkToResentVerificationLink');
}
});
The problem is that nothing happens. The user is not redirected even when I change the boolean in the emails[0].verified
field to 'true' or 'false' (doesn´t matter, nothing happens), but I also do not receive any error code.
Therefore I think the problem is in the if(...&& Meteor.user().emails[0].verified)
. Is there another way to find out whether a email is verified?
You can't use this.userId on the client. It only works on server side. try to use Meteor.userId() .