Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

340
Views
login with mails added to checklist -javascript

Have a realtime db login auth rules.

When I enter the mails manually, the mails I authorize gain access, there is no problem. Here is code:

{
  "rules": {
    ".read": "
                 auth.token.email == \"xx@qq.co\"  
                 || auth.token.email == \"yy.yy@yy.co\" 
                 || auth.token.email == \"ss@ss.com\"
    ",
      
    ".write": true
  }
}

But my idea:

{"emails":{"xx@hotmail.com", "qq@gmail.com"},
{
  "rules": {
    ".read": "auth.token.email == emails",
      
    ".write": true
  }

and realtime db code screenshot:

enter image description here

any idea this issue?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

That second snippet looks like invalid syntax for Firebase security rules, and thus won't work (it actually shouldn't even save when you enter that in the Firebase console).

If you want a dynamic list of user to gain access, the idiomatic way is to store their UIDs in the database and then check against that in your security rules.

So for example, you could have this in the database:

"uidsThatAreAllowedToRead": {
  "uid1": true,
  "uid2": true,
  "uid3": true
}

And then in your read rule check against that with:

".read": "root.child('uidsThatAreAllowedToRead').child(auth.uid).exists()"

You could do the same with email addresses, but you'd have to encode them as keys cannot contain . characters which are required in an email address. The common encoding method is to replace each . with a ,, which conveniently is allowed in the database keys but not in email addresses.

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!