事实发生后,Firebase通过电子邮件合并用户帐户 [英] Firebase merge user account by email after the fact

查看:62
本文介绍了事实发生后,Firebase通过电子邮件合并用户帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我一直在使用Firebase身份验证,并且一直在使用Facebook和Google登录名.当我开始时,不可能(或者我不知道)您可以限制每封电子邮件的帐户,并使用Firebase数据库安全规则和一些代码来处理它.现在在数据库中,每封电子邮件只有一个帐户,但是在身份验证帐户中,每封电子邮件有多个帐户.我想合并它们,或者在每个电子邮件规则中添加一个帐户.那可能吗?如果是,怎么办?如果没有,是否有任何解决方法?让人们合并帐户真是太好了.谢谢!

I have been using Firebase authentication for a while and I have been using Facebook and Google logins. When I started it was not possible (or I didn't know) that you can limit on account per email and took care of it with Firebase database security rules and some code. In the database now I only have one account per email, but in the authentication accounts I have multiples per email. I would like to merge them or after the fact add the one account per email rule. Is that possible? If yes, how? And if not, is there any work around? It would be great to let people merge accounts. Thanks!

推荐答案

即使在Firebase身份验证中创建了某些帐户之后,也可以使用同一封电子邮件合并帐户.

It is possible to merge accounts with the same email, even after some accounts have been created in Firebase Authentication.

第一步是通过更改Firebase项目控制台中的设置来禁止每个电子邮件多个帐户.更改将仅应用于新用户-所有现有用户仍将像以前一样登录其现有帐户.

First step is to disallow multiple-accounts-per-email by changing the setting in your Firebase project console. The change will only be applied to new users - all existing users will still sign into their existing accounts as before.

由于您的应用仅使用Google/Facebook登录,因此您可以从Firebase控制台中安全删除不需要的身份验证帐户.假设在数据库中有一个条目(userid_1,电子邮件),并且在您的身份验证项目中,有两个电子邮件帐户(userid_1,电子邮件,Google)和(userid_2,电子邮件,Facebook).您可以使用Firebase控制台或Firebase管理SDK .所有后续使用相同电子邮件进行的登录,无论是通过Google还是Facebook,都将始终返回userid_1帐户.

Since your app only uses Google/Facebook login, you can safely delete unwanted authentication accounts from the Firebase Console. Assuming in your database there is an entry (userid_1, email), and in you authentication project there are two accounts for the email (userid_1, email, Google) and (userid_2, email, Facebook). You can delete the (userid_2, email, Facebook) account using the Firebase Console or Firebase admin SDK. All subsequent logins with the same email, no matter via Google or Facebook, will always return the userid_1 account.

这篇关于事实发生后,Firebase通过电子邮件合并用户帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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