Firebase会为同一用户验证多个电子邮件地址 [英] Firebase verify multiple email addresses for the same user

查看:128
本文介绍了Firebase会为同一用户验证多个电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Firebase网络版SDK 4.0.0,希望让我的用户能够验证同一个帐户的多个电子邮件地址。对于上下文,我的目标是接收来自dave@home.com和dave@work.com的电子邮件,并且知道它肯定来自Dave(uid 123456789)。



I已经查阅了有关连接帐户的文档,但我认为这种方法是不会工作,因为我需要多个电子邮件。



我考虑将这些电子邮件存储在数据库中,并将它们链接到用户,但是这并不涉及Firebase验证过程(我想使用它)。

任何想法如何处理这个问题将是非常有帮助的。

解决方案

如果你想让一个用户在他的账户中注册多个邮件。您必须在Firebase数据库中进行链接。

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

userList:{
abc123:{
userName:James,
职业:程序员,
userAccounts:{
userId001:{
userAuth:userId001
},
userId002:{
userAuth:userId002
}
}
}






$ p

有了这个结构,你仍然可以使用firebase身份验证来验证他们的电子邮件地址。


$ b userId001 userId002 是通过Firebase身份验证创建的RNG。
$ b

里面的userRNGId(比如abc123)你应该创建随机的用户ID,以便所有的电子邮件将链接到该ID。



我希望它可以帮助。


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.

解决方案

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.

这篇关于Firebase会为同一用户验证多个电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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