0

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
Jaybruh
  • 333
  • 5
  • 14

1 Answers1

1

You can't use this.userId on the client. It only works on server side. try to use Meteor.userId() .

Andrei C
  • 61
  • 2
  • 5
  • lol, you are absolutely right. I just did it without 'this.userId' and now it works...Maybe I just did not get what 'this.userId' actually does...Could you maybe explain it to me? However, thanks. – Jaybruh Feb 27 '17 at 12:59