5

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!

koceeng
  • 2,169
  • 3
  • 16
  • 37
Mufad
  • 191
  • 1
  • 15
  • 1
    I think you need to quote the whole expression: `"a || b"`, in your case you can simply use `".write": true`, see https://firebase.google.com/docs/database/security/ –  Dec 26 '16 at 06:27
  • what about space not sure but a guess!!! – Trikaldarshiii Dec 26 '16 at 09:09

2 Answers2

9

Try This

{
    "rules:{
        ".read": "auth == null",
        ".write": "auth != null || auth==null"
    }
}
koceeng
  • 2,169
  • 3
  • 16
  • 37
Mihodi Lushan
  • 670
  • 5
  • 24
4

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 } }

Anchal Singh
  • 329
  • 3
  • 13