I've got Firebase data structured a little something like this:
+ tasks
+ task_id
+ title
+ user
+ ...
+ users
+ ...
The from the frontend (using AngularJS and AngularFire (plus the built in SimpleLogin)) - when a logged in user creates a task, the user's uid (eg. simplelogin:2) is placed into the user part of the task being created.
When a user is logged in, they can view only their tasks by using the:
$firebase( ref.orderByChild('user').equalTo(User.uid) );
The next step is to secure the data, which is where I'm struggling. I've tried:
"tasks": {
".indexOn": ["user", "order"],
".write": "auth != null",
".read": "auth != null && data.child('user').val() == auth.uid",
"$task": {
"title": {
".validate": "newData.isString() && newData.val().length <= 1000"
},
"completed": {
},
"time_added": {
".validate": "newData.val() <= now"
},
"order": {
},
"user": {
".validate": "newData.val() != null && newData.val() == auth.uid"
},
"$other": {
".validate": false
}
}
}
and also:
"tasks": {
"$task": {
".indexOn": ["user", "order"],
".write": "auth != null",
".read": "auth != null && data.child('user').val() == auth.uid",
"title": {
".validate": "newData.isString() && newData.val().length <= 1000"
},
"completed": {
},
"time_added": {
".validate": "newData.val() <= now"
},
"order": {
},
"user": {
".validate": "newData.val() != null && newData.val() == auth.uid"
},
"$other": {
".validate": false
}
}
}
However I get:
Error: permission_denied: Client doesn't have permission to access the desired data.
Where am I going wrong?