Search code examples
meteoremail-verification

Meteor: Resend email verification link


I want to be able to resend an email verification link to users of my Meteor application in case they accidentally delete their email verification email.

I have a link with the id "resentEmailVerificationLink"

I have the following code in my client for when the link is click (alerts are just there to show myself how far the function gets before an error):

Template.dashboard.events({
    'click #resentEmailVerificationLink' : function(event) {
        event.preventDefault();
        var id = Meteor.userId();
        alert('clicked: ' + id);
        Accounts.sendVerificationEmail(id);
        alert('Verification Email resent');
        return false;   // Stops page from reloading
    }
)};

I know the sendVerificationEmail is a server function but I have no idea how to call this function in the server upon clicking the verify email link (I'm a bit of a Meteor newbie).

Any idea of how to accomplish this, because currently it doesn't work with the following error: Uncaught TypeError: Accounts.sendVerificationEmail is not a function

Note: Meteor.Accounts.sendVerificationEmail(id); doesn't work either (it does however produce a different error.


Solution

  • You can try with server side method just create one pass the attrs and call http://docs.meteor.com/#/full/accounts_sendverificationemail on the server. More about meteor methods: http://docs.meteor.com/#/full/meteor_methods