mardi 3 septembre 2019

How to set specific rules to all data stored in real-time database

I am doing an online library system storing the file name,download url of the book(from firebase storage) and the authd.uid of the user in real-time database what I want to do is to update the database rules and to allow only the current authenticated user to access the data

that is my javascript code to put the values in database it works for me but the problem is that user cannot read the data

const postData={
          url:downloadURL,
          name:bookFile.name,
          uid:user.uid
      };
      updates[postBook+'/'+postKey]=postData;
     firebase.database().ref().update(updates);

that is what I tried to do with database rules but it is not working for me

{
  /* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */
  "rules": {
    ".read": "data.child('uid').val() ==auth.uid",
      ".write": "auth.uid!=null"
  }
}




Aucun commentaire:

Enregistrer un commentaire