如何像firebaseui一样检查电子邮件地址是否已在firebase auth上注册?

时间:2020-02-01 11:15:34

标签: javascript firebase firebase-authentication firebaseui

firebaseui的登录顺序。

登录顺序仅以电子邮件地址开头。

enter image description here

如果地址已注册到Firebase,则登录将继续。

enter image description here

如果未添加,将创建一个新帐户。

enter image description here

我的问题

与firebaseui一样,如何检查已在firebase auth上注册或未注册的电子邮件地址? 我正在寻找合适的API来检查电子邮件地址(是否已添加)。我搜索了 文档firebase. auth. Auth,但找不到。 我尝试使用firebase.auth().signInWithEmailAndPassword(this.email, "")并期望得到错误 auth / user-not-found ,但是我得到了 auth / wrong-password 。 / p>

1 个答案:

答案 0 :(得分:1)

您可以从文档中使用以下方法:

fetchSignInMethodsForEmail

fetchSignInMethodsForEmail(email: string): Promise<Array<string>>

获取给定电子邮件地址的可能登录方法的列表。这对于区分同一提供商的登录方法很有用。 EmailAuthProvider具有两种登录方式:电子邮件/密码和电子邮件/链接。

错误代码

auth / invalid-email 如果电子邮件地址无效,则引发该事件。

参数

email: string

Returns Promise<Array<string>>

如果未注册电子邮件,将返回错误

相关问题