简体   繁体   English

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

[英]How can I check an email address has been registered or not on the firebase auth, like as the firebaseui does it?

The login sequence of the firebaseui. firebaseui的登录顺序。

The login sequence starts with only an email address.登录序列仅以电子邮件地址开始。

在此处输入图片说明

In case the address has been registered to the firebase, login will continue.如果地址已注册到 firebase,登录将继续。

在此处输入图片说明

If not added, a new account will be created.如果不添加,将创建一个新帐户。

在此处输入图片说明

My Question我的问题

How can I check an email address that has been registered or not on the firebase auth, as the firebaseui does it?我如何检查已在 firebase auth 上注册或未注册的电子邮件地址,就像 firebaseui 一样? I'm looking for the appropriate API to check the email address if it has been added or not.我正在寻找合适的 API 来检查电子邮件地址是否已添加。 I've searched on the document firebase.我已经在文档firebase上搜索过 auth. 授权。 Auth , but I can't find it. Auth ,但我找不到它。 I've tried the firebase.auth().signInWithEmailAndPassword(this.email, "") with expect to get the error auth/user-not-found , but I've get auth/wrong-password .我试过firebase.auth().signInWithEmailAndPassword(this.email, "")期望得到错误auth/user-not-found ,但我得到了auth/wrong-password

You can use the following method, from the docs:您可以使用以下方法,来自文档:

fetchSignInMethodsForEmail

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

Gets the list of possible sign in methods for the given email address.获取给定电子邮件地址的可能登录方法列表。 This is useful to differentiate methods of sign-in for the same provider, eg.这对于区分同一提供商的登录方法很有用,例如。 EmailAuthProvider which has 2 methods of sign-in, email/password and email/link. EmailAuthProvider 有 2 种登录方法,电子邮件/密码和电子邮件/链接。

Error Codes错误代码

auth/invalid-email Thrown if the email address is not valid. auth/invalid-email 如果电子邮件地址无效则抛出。

Parameters参数

email: string

Returns Promise<Array<string>>

This will return an error if the email is not registered如果电子邮件未注册,这将返回错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM