Привет, ребята, я новичок в Firebase, и я пытаюсь разработать простое приложение для чата. До сих пор я получил аутентификацию, выполнив действия, описанные в документации Firebase.Не удается прочитать данные из Firebase после аутентификации
Это мой метод Войти
loginUser: function(){
console.log("Login button");
var self = this;
ref.authWithOAuthPopup("github", function(error, authData) {
if (error) { console.log("Login Failed!", error);}
else {
console.log(authData);
ref.child("users").child(authData.uid).set({
auth : authData.auth,
provider : authData.provider,
name : authData.github.displayName,
imgUrl : authData.github.profileImageURL,
token: authData.token
});
self.user.name = authData.github.displayName;
self.user.imgUrl = authData.github.profileImageURL;
self.user.provider = authData.provider;
setTimeout(function(){ self.authenticated = true; }, 2000);
this.getContacts();
}
},{
remember : "sessionOnly",
scope: "user"
});
}
и это метод getContacts (я утешал снимок, но я ничего не получил)
getContacts: function(){
console.log('GET CONTACTS');
var self = this;
//retrieving all the user, but for somehow this request doesn't execute
ref.child('users').once('value',function(snapshot){
var contacts = snapshot.val();
console.log(contacts);
for(var contact in contacts){
self.contacts.push({
id: contact,
name: contacts[contact].name,
imgUrl: contacts[contact].imgUrl,
provider: contacts[contact].provider
});
}
});
}
это правила безопасности
{
"rules": {
"users": {
"$uid": {
// grants write access to the owner of this user account whose uid must exactly match the key ($uid)
".write": "auth !== null && auth.uid === $uid",
// grants read access to any user who is logged in with GitHub
".read": "auth !== null && auth.provider === 'github'"
}
}
}
Должен отметить, что я использую Vuejs
Большое вам спасибо, сейчас это работает !!! – AngelSalazar