Permission Denied in Firebase

2

I'm developing an app with ionic 3 and Firebase ... In the Realtime Database rules, the problem arises: I try put the rules pro type "user", but the following error appears:

  

ERROR Error: Uncaught (in promise): Error: PERMISSION_DENIED:   Permission denied

     

ERROR Error: permission_denied at / orders: Client does not have   permission to access the desired data.

Rule structure:

{
  "rules": {
    "users": {
      "$uid": {
        ".read": "$uid === auth.uid",
        ".write": "$uid === auth.uid"
      }
    }
  }
} 
    
asked by anonymous 19.09.2018 / 20:52

2 answers

0

I think the Firebase database rules are set to read / write = false , so you can not develop. To fix this, simply access the rules in the Firebase Console > Realtime Database and change the settings to true .

More information here

    
19.09.2018 / 21:30
0

From a comment:

  

I need only the user to be able to read and write your requests.

First, we can try to organize this way, see if this matches your needs:

- users
   - uid
      - pedidos
         - idPeDIDoLE7NyOSXaLSZ
            - name: "ASDF"
            - tel: "23"
         - idPeDIDoYWchTgdMk9W1
            - name: "FDSA"
            - tel: "94"

Rules:

{
  "rules": {
    "users": {
      "$uid": {
        //".read" : "$uid === auth.uid",
        "pedidos": {
          ".read" : "$uid === auth.uid",
          ".write" : "$uid === auth.uid"
        }
      }
    }
  }
}

or this way

- users
   - uid
    //- Informações do usário aqui, nome, email etc.
- uid
   - pedidos
      - idPeDIDoLE7NyOSXaLSZ
         - name: "ASDF"
         - tel: "23"
      - idPeDIDoYWchTgdMk9W1
         - name: "FDSA"
         - tel: "94"

Rules:

{
  "rules": {
    "$uid": {
      //".read" : "$uid === auth.uid",
      "pedidos": {
        ".read" : "$uid === auth.uid",
        ".write" : "$uid === auth.uid"
      }
    }
  }
}
    
21.09.2018 / 02:17