sendEmailVerification vs sendSignInLinkToEmail for email verification using firebase

Viewed 836

I am trying to set up email verification on an existing project. I stumbled into two different documentation that uses two different methods for this but still follows the same flow

  1. sendEmailVerification
  2. sendSignInLinkToEmail

The only difference that I saw was that we have to specifically create the ActionCodeSettings object when using sendSignInLinkToEmail so as to specify that it is being used for verification whereas this is not needed when using sendEmailVerification.

I am assuming, the main difference in the explanation of the docs was that one was used in authenticating the user, and the other was used to verify the user. Although this security StackExchange post helped me understand the difference a little bit, I still am confused about how it differentiates in the context of the user's sign in experience

1 Answers

One is for authentication, the other is to validate the email.

sendEmailVerification is a one-time event to verify that the user's email address is valid. It sets the emailVerified value in the User object. Once the email is verified you wouldn't call it again. This is used during the registration process.

sendSignInLinkToEmail is an authentication method that allows a user to log in by clicking a link that's sent to them by email instead of entering an email/password or logging in through a federated account. If this is the user's preferred authentication method, you would call this every time the user wants to log in.

Related