Doge
Doge

Reputation: 863

auth.uid is not working

Rule:

{
  "rules": {
    "userdata":{
        "$id":{

         ".read": "(auth.uid=='aI2OGxb2pnY58ix5ugZLv0rhZqn2')",
         ".write": "(auth.uid=='aI2OGxb2pnY58ix5ugZLv0rhZqn2')"


    }
    }
  }
}

Actually my rule is so different. But to confirm that auth.uid is not working for me. I added this into my rules and I got same result (Permission Denied).

And my original uid is also same as given in the above rules.

So are there anything wrong in the rule structure or I'm doing anything wrong in firebase configuaration.

Thanx

Upvotes: 1

Views: 322

Answers (1)

Alex Mamo
Alex Mamo

Reputation: 138824

Don't forget to set read and write rules to false.

{
  "rules": {
    ".read": "auth != false",
    ".write": "auth != false",
    "userdata":{
      "$id":{
       ".read": "auth.uid == $id",
       ".write": "auth.uid == $id",
      }
    }
  }
}

Hope it helps.

Upvotes: 2

Related Questions