Firebase 身份验证将电子邮件与电话连接 [英] Firebase Authentication connect Email with Phone

查看:32
本文介绍了Firebase 身份验证将电子邮件与电话连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用 Firebase 的电子邮件电话号码身份验证.

I am currently using Email and Phone number authentication using Firebase.

我有 3 EditText 用于:

And i have 3 EditText for:

  • 电子邮件
  • 电话号码
  • 密码

但问题是当用户完成注册后,它显然会创建2 个帐户实例,一个用于电子邮件,第二个用于电话号码.

But the problem is when the user is done registering it obviously creates 2 instance of accounts, one for the Email and second for the Phone number.

我想将电子邮件电话号码作为一个帐户链接在一起.有没有办法做到这一点?

I would like to link the Email and Phone number together as one account. Is there any way to do that?

推荐答案

取决于您是否允许使用电子邮件或电话号码登录,或者是否允许将电话号码用作第二个因素,对于登录,有不同的解决方案.

Depending on whether you want to allow for signing in with either email or phone number, or if you want to allow for the Phone number to be used as a second factor, for sign in, there are different solutions.

如果您只想将电话号码作为第二种登录方式,您可以在 Firebase 用户上使用 linkWithCredential 方法链接凭据.通过这种方式,您可以根据需要添加任意多种登录方式.Firebase 有关于此的良好指南.

If you just want to have the Phone number be a second way to sign in, you can link the credentials using the linkWithCredential method on your Firebase User. This way you can add as many ways to sign in, as you want. Firebase has a good guide on this.

如果您希望电话号码成为身份验证的第二个因素,您将需要一个自定义身份验证提供程序,它执行第二个因素身份验证.还有一个入门指南,但是 2 Factor Authentication部分本身取决于您.

If you want the phone number to be a second factor of authentication, you will need to have a custom auth provider, which does the second factor authentication. There is also a getting started guide on this, however the 2 Factor Authentication part itself would be up to you.

这篇关于Firebase 身份验证将电子邮件与电话连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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