Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Or operator '||' not working in firebase rules

I'm trying to change my firebase realtime database rules so that I can access it from both authenticated and unauthenticated users, I changed them to

{
  "rules": {
    ".read": "auth == null",
    ".write": "auth != null" ||"auth==null"
  }
}

But the or operator || is not working. What should I do?

Thanks!

like image 519
Mufad Avatar asked Dec 11 '22 13:12

Mufad


2 Answers

Try This

{
    "rules:{
        ".read": "auth == null",
        ".write": "auth != null || auth==null"
    }
}
like image 191
Mihodi Lushan Avatar answered Dec 28 '22 22:12

Mihodi Lushan


Also, If you want to allow both users authenticated and non-authenticated , it means you want to allow all users to access database, then you can do this :

These rules give anyone, even people who are not users of your app, read and write access to your database

{ "rules": { ".read": true, ".write": true } }

like image 39
Anchal Singh Avatar answered Dec 29 '22 00:12

Anchal Singh