4
I made a small test app using Firebase.
Everything works great when I leave the rules for anyone to have access to the database
".read":"true",
".write":"true"
But when I added permissions in the Rules to limit access from where each user can read, I can no longer read anything in the apk.
{
"rules":
{
"comandos":
{
"$unit_id":
{
".read":"root.child('unidades').child($unit_id).hasChild(auth.uid)",
".write":"root.child('unidades').child($unit_id).hasChild(auth.uid)"
}
}
}
}
When I simulate reading and recording in the firebase simulator the rules work perfectly. So I guess I’m doing something wrong with the reading.
The login is working perfectly using the FirebaseAuth
, I receive confirmation by FirebaseAuth.AuthStateListener
, but I don’t know how to "turn on" this login to my Firebase reference. And when I try to login using
mRef = new Firebase(url);
mRef.authWithPassword(email, pass, new Firebase.AuthResultHandler(){...});
I receive the message that I should use FirebaseAuth
,
Projects created at console.firebase.google.com must use the
new Firebase Authentication SDKs available from firebase.google.com/docs/auth/
I must be letting something extremely simple go unnoticed, but I have no idea how to receive the data now that I am requiring a login, since the Firebase reference firebase.getAuth()
always this as null, and the data arrive by the method
firebase.addChildEventListener(new ChildEventListener(){...});
@Edit
//build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.google.firebase:firebase-core:9.0.2'
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'com.google.firebase:firebase-auth:9.2.0'
}
Put your Radle on please
– Caique Oliveira
@christian-beregula its understood well, its problem is in knowing which is the Liener that is listening the status of the authentication?
– Felipe Arimateia