Database:
"user_locations": {
"123": {
"user_id": "kcf3566"
}
}
Rule:
"user_locations": {
"$loc_id": {
".read": "auth.uid == root.child('user_locations/$loc_id/user_id').val()",
".write": "auth != null"
}
}
Per the above code, I am trying to allow ONLY users with the with a matching uid at the path user_locations > $key > uid to be able to read the data. I tried the above rule, however, I am unable to access the data.
The code that triggers the problem:
$scope.get_user_locations = function () {
firebase.auth().onAuthStateChanged(function (user) {
if (user) {
var returned_locations = firebase.database().ref('user_locations/');
returned_locations.on('value', function (snapshot) {
$scope.user_locations = snapshot.val();
});
} else {
$state.go('login');
}
});
};