So I have a Firebase that contains a list of objects all belonging to different vendors. I have restricted access to the locations using the rule:
{
"rules": {
"purchases": {
".indexOn": "code",
"$purchaseId": {
".read": "root.child('vendors').child(data.child('vendor').val()).child('id').val() == auth.uid",
".write": "root.child('vendors').child(data.child('vendor').val()).child('id').val() == auth.uid"
}
}
}
This rule works as expected in the simulator.
I now want to run a query on the purchases as a logged in vendor to only retrieve my purchases. The query itself works fine if I have full admin access (i.e. from a token-based auth login), but doesn't work from a vendor (email/password) login.
Is this not possible?
I just want to return all the purchases that are authorised for my login.
My query is like this
var ref = new Firebase("https://example.firebaseio.com");
var query = ref.orderByChild("vendor").equalTo(vendorId);
query.on("child_added", function(purchases) {
console.log(purchases.val());
});
Is there another way of achieving this without restructuring my Firebase?