使用 firebase 进行电子邮件验证的 sendEmailVerification 与 sendSignInLinkToEmail

sendEmailVerification vs sendSignInLinkToEmail for email verification using firebase

我正在尝试为现有项目设置电子邮件验证。我偶然发现了两个不同的文档,它们为此使用了两种不同的方法,但仍然遵循相同的流程

  1. sendEmailVerification
  2. sendSignInLinkToEmail

我看到的唯一区别是我们在使用sendSignInLinkToEmail时必须专门创建ActionCodeSettings对象,以指定它用于验证,而在使用时则不需要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

一个用于身份验证,另一个用于验证电子邮件。

sendEmailVerification 是一次性事件,用于验证用户的电子邮件地址是否有效。它在 User object 中设置 emailVerified 值。验证电子邮件后,您就不会再调用它。这在注册过程中使用。

sendSignInLinkToEmail 是一种身份验证方法,允许用户通过单击通过电子邮件发送给他们的 link 而不是输入 email/password 来登录或通过联合帐户登录。如果这是用户首选的身份验证方法,您将在每次用户想要登录时调用它。