Firebase verify multiple email addresses for the s

2020-07-18 06:41发布

I'm using Firebase web SDK 4.0.0 and want to enable my users to verify multiple email addresses for the same account. For context, my objective is to receive email from dave@home.com and dave@work.com and know that it's definitely coming from Dave (uid 123456789).

I've looked up the docs about linking accounts but I'm assuming this approach isn't going to work as I need multiple emails.

I thought about storing the emails in the db and linking them to the user but that doesn't hook into the Firebase verification process (which I want to use).

Any ideas of how to approach this would be very helpful.

1条回答
趁早两清
2楼-- · 2020-07-18 06:48

If you want a user have multiple emails registered in his account. You have to do the linking in the firebase database. Below is how to implement the structure in the database.

{
  "userAuth": {
    "userId001": {
      "userRNGId": "abc123",
      "userEmail": "example01@gmail.com"
    },
    "userId002": {
      "userRNGId": "abc123",
      "userEmail": "example02@gmail.com"
    }
  },

  "userList": {
    "abc123": {
      "userName": "James",
      "occupation": "Programmer",
      "userAccounts": {
        "userId001": {
          "userAuth": "userId001"
        },
        "userId002": {
          "userAuth": "userId002"
        }
      }
    }
  }
}

With this structure you can still use firebase authentication to verify their email address.

userId001 and userId002 is the RNG created from firebase authentication.

Inside userRNGId(E.g abc123) you should create random user ID so that all the emails will be linked to that id.

I hope it helps.

查看更多
登录 后发表回答