簡體   English   中英

為每個身份提供者創建多個帳戶的選項在 Firebase 身份驗證中未按預期工作

[英]Option of create multiple accounts for each identity provider not working as expected in Firebase Authentication

如下圖所示,我啟用了第二個選項(為每個身份提供者創建多個帳戶)

在此處輸入圖像描述

現在這個 email m6454611@gmail.com已經在 Firebase 身份驗證中,我已經使用 Google 提供程序登錄。

我想用上面相同的 email 但使用 email 提供程序創建一個新帳戶,但它告訴我 email 帳戶注冊不成功。 如果我刪除通過 Google 提供商登錄的 email,它將正常工作。

在此處輸入圖像描述

我預計它將創建相同的 email 沒有任何問題,因為它是不同的提供者

我是不是誤會了什么?

要將多個提供商鏈接到同一個帳戶,您不使用 create user 方法,有一個鏈接方法:

https://firebase.google.com/docs/auth/web/account-linking

import { getAuth, linkWithCredential } from "firebase/auth";

const auth = getAuth();
linkWithCredential(auth.currentUser, credential)
  .then((usercred) => {
    const user = usercred.user;
    console.log("Account linking success", user);
  }).catch((error) => {
    console.log("Account linking error", error);
  });

基本上,行為是該帳戶已創建並已登錄,然后您可以將其現有帳戶與新的提供商鏈接。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM