简体   繁体   English

如何将备份的 email 地址链接到 firebase 电话身份验证?

[英]How to link a backup email address to a firebase phone authentication?

I'm using a Firebase phone auth as primary authentication.我使用 Firebase 电话身份验证作为主要身份验证。 Since the phone is vulnerable, I want to link an email address to it that the user can use to access his account to change his phone number in case he lost his phone or got stolen.由于手机易受攻击,我想将一个 email 地址链接到它,用户可以使用该地址访问他的帐户以更改他的电话号码,以防手机丢失或被盗。 I can't find a way how to do it.我找不到怎么做的方法。 I saw a method currentUser.linkWithPhoneNumber() .我看到了一个方法currentUser.linkWithPhoneNumber() However, reading its documentation, it says it is only supported on web platforms.然而,阅读它的文档,它说它只在 web 平台上受支持。 Is there any other way to make this possible?有没有其他方法可以使这成为可能?

When you authenticate a user with a phone number, the only data that you have inside the FirebaseUser object when the authentication completes, are the UID and the phone number.当您使用电话号码对用户进行身份验证时,身份验证完成后您在 FirebaseUser object 中拥有的唯一数据是 UID 和电话号码。 If you need to add an email address to an existing account, you can request the user to provide an email address.如果您需要将 email 地址添加到现有帐户,您可以要求用户提供 email 地址。 Once you have that, you can update the email address using the FirebaseUser#updateEmail(String email) function.完成后,您可以使用FirebaseUser#updateEmail(String email) function 更新 email 地址。 As soon as the account is updated, you can add any functionality related to that email address.帐户更新后,您可以添加与该 email 地址相关的任何功能。

Since you didn't specify a programming language, I linked that function to the Android docs, but certainly, you can do the same thing in the case of any other programming languages.由于您没有指定编程语言,我将 function 链接到 Android 文档,但当然,您可以在任何其他编程语言的情况下做同样的事情。

upon further reading, i found Email Link Authentication that answered everything i've asked.进一步阅读后,我发现Email Link Authentication回答了我所问的所有问题。

Linking/re-authentication with email link You can also link this method of authentication to an existing user. For example a user previously authenticated with another provider, such as a phone number, can add this method of sign-in to their existing account.

https://firebase.google.com/docs/auth/flutter/email-link-auth https://firebase.google.com/docs/auth/flutter/email-link-auth

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

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