Firebase 身份验证 - 使用电子邮件和密码 - 检查用户已注册 [英] Firebase Auth - with Email and Password - Check user already registered

查看:28
本文介绍了Firebase 身份验证 - 使用电子邮件和密码 - 检查用户已注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查用户何时尝试使用 Firebase 用户身份验证方法中的 createUserWithEmailAndPassword() 进行注册,此用户已在我的应用中注册.

I want to check when a user attempts to signup with createUserWithEmailAndPassword() in Firebase user Authentication method, this user is already registered with my app.

推荐答案

要检测具有该电子邮件地址的用户是否已存在,您可以检测何时调用 createUserWithEmailAndPassword () 失败并返回 auth/email-already-in-use.我看到@Srinivasan 刚刚为此发布了一个答案.

To detect whether a user with that email address already exists, you can detect when the call to createUserWithEmailAndPassword () fails with auth/email-already-in-use. I see that @Srinivasan just posted an answer for this.

或者,您可以通过调用 fetchSignInMethodsForEmail().通常的流程是,您首先要求用户输入他们的电子邮件地址,然后调用 fetchSignInMethodsForEmail,然后将他们移动到一个屏幕,该屏幕要么询问他们的其余注册详细信息(如果他们新),或向他们展示他们已经注册的提供商.

Alternatively, you can detect that an email address is already used by calling fetchSignInMethodsForEmail(). The usual flow for this is that you first ask the user to enter their email address, then call fetchSignInMethodsForEmail, and then move them to a screen that either asks for the rest of their registration details (if they're new), or show them the provider(s) with which they're signed up already.

这篇关于Firebase 身份验证 - 使用电子邮件和密码 - 检查用户已注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆