Currently I've been looking at FireBase, and have been using the AngularJS plugin, and have found the following problem I cannot get out of.
I currently have implemented the simple login system. Logged in with my mail and password after registering, I create a post like this:
post = {
name: "Hi",
message: "Guys",
user_id: Auth.user.id // for my current user this is 1
}
posts.$add(post)
From this point on everything is fine. Now what I wanted to do is that in the posts/ endpoint on firebase, I want only to display the posts of the user currently logged in.
Other users may be able to read posts of others by having a public boolean variable (but that's for later)
I've been looking at the security API of Firebase (see: https://www.firebase.com/docs/security/security-rules.html) Currently I have this:
{
"rules": {
"posts": {
"$post": {
".read": "data.child('user_id').val() == auth.id",
".write": "(data.child('user_id').val() == auth.id) || (newData.child('user_id').val() == auth.id)"
}
}
}
}
It works to a certain extend, I can write posts only if I'm logged in, but I cannot read any posts!
posts = new Firebase(base + '/posts')
posts = $firebase(posts)
The error is: FIREBASE WARNING: on() or once() for /posts failed: Error: permission_denied: Client doesn't have permission to access the desired data.
If anyone has a solution then that would be awesome!