On my server I made accounts require email verification and to send the verification email:
Accounts.config({sendVerificationEmail: true, forbidClientAccountCreation: false});
I read somewhere online that the verification link will redirect the user to the home page of the web app once clicked.
On that home page I try to catch the first time it gets confirmed as I would like to add some entries to the MONGO DB the FIRST TIME the email gets verified and the user gets authenticated.
So I try to get this confirmation on the client side by doing this:
Template.home.created = function(){
if (Accounts._verifyEmailToken) {
Accounts.verifyEmail(Accounts._verifyEmailToken, function(err) {
if (err != null) {
if (err.message = 'Verify email link expired [403]') {
console.log('Sorry this verification link has expired.')
}
} else {
console.log('Thank you! Your email address has been confirmed.')
}
});
}
}
Unfortunately I NEVER got console.log('Thank you! Your email address has been confirmed.')
to log in the console.....
I always get console.log('Sorry this verification link has expired.')
even after the first time I click on it.
What am I missing here???
How do I get a function to be called the first time the email gets verified???
Thank you.