Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we have Email Id as key in Firebase database? [duplicate]

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.

The JSON structure I want is:

{
  "[email protected]":
       {
            "EID":"0153"
        },
   "[email protected]":
       {
               "EID":"0163"
        }
}

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.

like image 698
joel Avatar asked Jan 05 '23 17:01

joel


1 Answers

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

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 [email protected]

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

So the structure should be:

{
    "<md5 hash of '[email protected]'>": { 
            "EID":"0153" 
     }, 
    "<md5 hash of '[email protected]'>": { 
             "EID":"0163" 
    }
 }
like image 110
Ketan Yekale Avatar answered Jan 07 '23 10:01

Ketan Yekale