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:
any idea this issue?
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.