简体   繁体   English

Firebase 身份验证提供商悄悄地将密码更改为 google.com

[英]Firebase authentication provider silently changes from password to google.com

I use firebase authentication for my web app with three providers: email-password, google, or facebook. I have enabled the option "One account per email address".我为我的 web 应用程序使用 firebase 身份验证,三个提供商:电子邮件密码、谷歌或 facebook。我启用了选项“每个 email 地址一个帐户”。

When a user signs up using email-password (with a gmail address), then later uses google sign-in, I expect to receive an exception "auth/account-exists-with-different-credential", but I do not.当用户使用电子邮件密码(地址为 gmail)注册,然后使用谷歌登录时,我希望收到异常“auth/account-exists-with-different-credential”,但我没有。 His providerId is changed to google.com and he cannot use his password anymore (throws "auth/wrong-password").他的 providerId 更改为google.com并且他不能再使用他的密码(抛出“auth/wrong-password”)。

Is this normal behaviour?这是正常行为吗?

Firebase Authentication has a concept of a preferred provider for certain email addresses. Firebase 身份验证具有特定 email 地址的首选提供者的概念。 The most common one is that google.com is the preferred provider for @gmail.com addresses, but I think they also exist for Facebook and Microsoft accounts.最常见的是 google.com 是@gmail.com地址的首选提供商,但我认为它们也存在于 Facebook 和 Microsoft 帐户中。

If an existing account later signs up again from a preferred provider, that provider overwrites the existing user account.如果现有帐户稍后再次从首选提供商处注册,则该提供商将覆盖现有用户帐户。 There is no way to change this behavior (that I know of).没有办法改变这种行为(我知道)。

Also see:另见:

This is how I'm solving it: https://firebase.google.com/docs/auth/android/account-linking这就是我解决它的方式: https://firebase.google.com/docs/auth/android/account-linking

Just link the "accounts".只需链接“帐户”。

Update 2023: 2023 年更新:

You can now choose if you want to allow 'User account linking'.您现在可以选择是否要允许“用户帐户链接”。 For example, if you don't allow multiple accounts with the same email address, a user cannot create a new account that signs in using a Google Account with the email address ex@gmail.com if there already is an account that signs in using the email address ex@gmail.com and a password.例如,如果您不允许多个帐户使用相同的 email 地址,则用户无法创建使用地址为 email 的 Google 帐户登录的新帐户 ex@gmail.com 如果已有帐户使用email 地址 ex@gmail.com 和密码。

If you do allow multiple accounts with the same email address, your app's sign-in flow cannot rely on an email address to identify a user account.如果您确实允许多个帐户使用相同的 email 地址,则您应用的登录流程不能依赖 email 地址来识别用户帐户。

You can find this under settings within Firebase Authentication.您可以在 Firebase 身份验证的设置下找到它。

There are some caveats to using this feature, please read about it here使用此功能有一些注意事项,请在此处阅读

Firebase 身份验证设置

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

相关问题 Firebase 身份验证:如何知道 Google 或 Facebook 提供商的帐户是否已经存在? - Firebase Authentication: How to know if account with Google or Facebook provider already exist? Firebase Auth - 没有来自谷歌登录提供商的电子邮件 - Firebase Auth - no email from google sign in provider 链接多个身份验证提供程序 | Firebase 认证 - Link multiple Authentication provider | Firebase Authentication unity Firebase 认证-无效密码 - Unity Firebase Authentication - invalid password 密码长度通过Firebase认证 - Password length through Firebase authentication 谷歌 Firebase 忘记密码 - Google Firebase forget password Firebase 谷歌身份验证错误 - Firebase error with Google Authentication java.lang.RuntimeException:无法获取提供商 com.google.firebase.provider.FirebaseInitProvider:java.lang.NullPointerException - java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.NullPointerException Vercel 部署和 Firebase 身份验证 - 无法自定义重定向 URL Google 身份验证提供程序弹出窗口 - Vercel Deployment and Firebase Authentication - Unable to Customise Redirect URL Google Auth Provider Popup Firebase 身份验证 - 忘记/重设密码 - Firebase Authentication - Forget/ Reset Password
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM