I have implemented rules in Firebase to restrict access to the data and when I simulate read / write priviledges in the Firebase Validator view the permission is granted. But when I run through VueFire no results are returned.
This is the structure of the database:
<firebase-id>:
-chat:
-messages:
- message1
- message2
- message3
This is my rules from Firebase:
{
"rules": {
"chat": {
"messages": {
"$message": {
".read": "auth != null && data.child('uid').val() == auth.uid",
".write": "auth != null && data.child('uid').val() == auth.uid"
}
}
}
}
}
I am logged in and authenticated, but i receive no results.
I have tried to grant access when authenticated which works when i put the rule on the chat level, messages level, but not if i put it on the $message level, which indicates that VueFire has trouble with the wildcards ($) ?
Has anyone else experienced something similar ? or have any ideas what is wrong?
Update: I found out that the validation fails when trying to access the array of messages, as I am trying.
Code snippet:
// Generate ref to messages fails validation
export const messages = firebaseRef.child('chat').child('messages');
// Generate ref to specifi message create by user passes validation
export const messages = firebaseRef.child('chat').child('messages').child('<message id>')
So access to this path is not granted, but only if i try to fetch one specific message. But how can i retrieve an array which only includes the items which passes the validation ?