我们可以在Firebase数据库中将电子邮件ID作为密钥吗? [英] Can we have Email Id as key in Firebase database?

查看:106
本文介绍了我们可以在Firebase数据库中将电子邮件ID作为密钥吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个登录系统,当用户登录时,基于 在登录用户的电子邮件ID上,我想检索EID.

I want to create a login system , when the user logs in, based on the logged in users email id, I want to retrieve the EID.

我想要的JSON结构是:

The JSON structure I want is:

{
  "joel@dept.com":
       {
            "EID":"0153"
        },
   "Stan@dept.com":
       {
               "EID":"0163"
        }
}

我尝试将具有上述结构的JSON文件导入Firebase项目数据库,但是出现错误提示"./..."不能成为密钥的一部分.

I tried importing the JSON file with above structure into the Firebase projects database, but got an error suggesting "./ ..." cannot be a part of key.

推荐答案

用一个字符替换另一个字符可能会导致混乱,并可能在将来引起严重问题.

Replacing one character with another may lead to confusion and may cause critical issues in future.

对于该实例,暂时可以将.替换为_DOT_.以后说您要取回原始电子邮件以进行验证; [没关系]我可以将_DOT_替换为..如果有人收到电子邮件actual._DOT_@actualdot.com

For the instance, replacing . with _DOT_ may work for now. Say in future you want to get back the original email for some verification; [no big deal] I can replace _DOT_ back with .. This fails if someone has the email actual._DOT_@actualdot.com

解决方案是使用电子邮件哈希.我现在更喜欢md5.

The solution is to use email hash. I prefer md5 at the moment.

因此结构应为:

{
    "<md5 hash of 'joel@dept.com'>": { 
            "EID":"0153" 
     }, 
    "<md5 hash of 'Stan@dept.com'>": { 
             "EID":"0163" 
    }
 }

这篇关于我们可以在Firebase数据库中将电子邮件ID作为密钥吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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