Home > Enterprise >  Email verification before user creation
Email verification before user creation

Time:02-19

According to the document, it is possible to have email verified when user().onCreate is triggered. From my understanding, you can send email verification link only after creating an account. How it is possible?

// On sign up.
exports.processSignUp = functions.auth.user().onCreate(async (user) => {
  // Check if user meets role criteria.
  if (
    user.email &&
    user.email.endsWith('@admin.example.com') &&
    user.emailVerified  // Is this can be true at this moment!?
  ) {
      // Grant access
    } catch (error) {
      console.log(error);
    }
  }
});

CodePudding user response:

The initial claims for a user profile are determined by the provider that creates the initial ID token for that user. So any provider can set the emailVerified claim if they want.

Example of built-in providers that do that:

  • When you sign the user in through an email link it implicitly already verified that they have access to the email address, so emailVerified is set to true.
  • Certain providers already know that the user owns a certain email address, such as Google for @gmail.com and Facebook for @facebook.com addresses, and may set emailVerified to true for such addresses automatically.
  • Related