Facebook主电子邮件更改后,Firebase不会更新Facebook用户的电子邮件

问题描述 投票:2回答:1

我有一个启用了Facebook登录功能的Firebase测试应用。我创建了一个测试FB帐户(称为[email protected]),通过FB登录登录到Firebase,使用返回的id通过email请求了FB配置文件数据,例如GraphRequestaccessToken

然后,我向FB帐户添加了另一封电子邮件(称为[email protected]),将主电子邮件从[email protected]更改为[email protected],然后从该帐户中删除了[email protected]。因此,从技术上讲,[email protected]现在已发布,并且不与FB帐户关联。

现在,当我使用[email protected]登录到Firebase时,Firebase会正确识别出它与之前登录的用户相同(因为FB凭据相同)。但是,当我在Firebase控制台中看到用户列表时,该用户的电子邮件仍然显示[email protected]

所以我用[email protected]创建了一个新的FB帐户,并尝试以此登录到我的Firebase应用程序。但是,由于我在Firebase身份验证设置中选择了“每个电子邮件地址一个帐户”选项,因此出现以下错误:

Error Domain=FIRAuthErrorDomain Code=17012 "An account already exists with
the same email address but different sign-in credentials. Sign in using a 
provider associated with this email address." UserInfo=
{error_name=ERROR_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL, 
[email protected], NSLocalizedDescription=An 
account already exists with the same email address but different sign-in  
credentials. Sign in using a provider associated with this email address.}

这意味着,即使我已经从FB帐户中释放了该电子邮件,并使用该释放的电子邮件创建了新用户,但我永远无法再次登录到我的应用程序(只要我选择了“每个电子邮件地址的帐户”选项在Firebase身份验证设置中)

所以我很好奇:FB帐户上的主要电子邮件更改后,Firebase是否没有更新第一个帐户上的电子邮件的原因?是虫子吗?因为GraphRequest响应会返回新电子邮件,所以从技术上讲,如果没有其他用户已经注册了新电子邮件,则Firebase应该能够对其进行更新。

firebase firebase-authentication facebook-login
1个回答
0
投票

我想Firebase不知道电子邮件已更改并且无法跟踪,因为Firebase没有访问用户帐户详细信息的权限,只有您的应用程序可以执行此操作。

您需要自行管理电子邮件更改方案。这是我在iOS上的操作方法:

1)每次用户打开应用程序时,我正在执行Graph API请求以获取新的用户数据。将此请求返回的电子邮件与该用户存储在Firebase中的电子邮件进行比较。

2)一旦我检测到电子邮件不同-我将更新存储在Firebase中的电子邮件以与Facebook的电子邮件保持同步。在iOS SDK中为:

Auth.auth().currentUser?.updateEmail(to: newEmail) { error in
    // if there was no error - the firebase now has the latest email
}
© www.soinside.com 2019 - 2024. All rights reserved.