Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Firebase database rules for particular field

I have a Firebase database JSON in a format

global_records
    field1:
private_records
    field_A:
    field_B

And I have rules set as

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

When I call observeSingleEventOfType to get globar_records I get the error permission_denied. This works when Sign In.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How do I only allow access to global_records to all the users and need to authenticate to access private_records?

>Solution :

you can add rules for your nodes separately.

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

    "private_records": {
      ".read": "auth != null"
      ".write": "auth != null"
    },
  }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading