SendVerificationEmail with loginWithFacebook Meteor/React

Hey guys, trying to sendVerificationEmailI() using loginWithFacebook()

Currently have this:

Accounts.onCreateUser(function(options, user) {
  if (!user.services.facebook) {
    return user;
  }

  const { facebook } = user.services;

  user.emails = [{ address: facebook.email, verified: false }];
  user.profile = {
    about: "",
    firstName: facebook.first_name,
    lastName: facebook.last_name,
  };

  return user;
});

Tried using sendEmailVerification(), the problem, however, that user._id is not available yet in this before the return user statement.

Was thinking about using callbacks, but cannot figure out how to

What is the best way to sendEmailVerification() with OAuth?

Edit: Stack with Meteor and React

Try a settimeout before returning. In it check for a user with the email address created and obtain the id. You could also use an interval instead of a timeout if the used Id was not available the first time.

I thought the verification email was sent automatically but the Facebook login may differ.

I would personally solve this using matb33:collection-hooks and a Meteor.users.after.insert hook.

3 Likes

Thank you Kelly!

Would this imply that there is no native solution to loginWithFacebook() similar to what Accounts.createUser() has with Meteor’s sendEmailVerification() ?

Cheers

I’ve never used Facebook login myself so I can’t say for sure.

Ok, thanks for the package reference!