Resending verification email (Solved)

Hello People,

I blocked logins using: Accounts.validateLoginAttempt till users verify their emails. However, I also want users to be able to resend the link, and it turns out I cannot use: Accounts.sendVerificationEmail( userId ); as the user doesn’t even get to login, so no userid is set. How do I circumvent it, my solution is very hackish and I want to do it the Meteor way.

Thanks.

Why don’t you give the user the ability to request a verification email by providing the email address he registered with? You can then lookup the user server side by the e-mail address provided.

Hello Jamgold,

Thank you for your response. I used:

Meteor.methods({
  resendVerificationLink() {
    var resendvar = Meteor.users.findOne({"emails.address": "email@example.com"}, {fields: {'_id': 1}});
    let userId = resendvar._id;
    if ( userId ) {
    console.log (Accounts.sendVerificationEmail( userId ))
      return Accounts.sendVerificationEmail( userId );
    }
  }
});

It works, wanted to know if there was a “Meteor Way” I was ignoring. Thanks.

I wouldn’t return it tho!