I'm having a weird problem with firebase. The auth variable is null. I use the simple login to log the users in:
$scope.login = function() {
$scope.auth.$login('google', {
scope: 'https://www.googleapis.com/auth/plus.me'
}).then(function(user) {
// The settings updated
$scope.settings.user = {
name: user.displayName,
email: user.email,
profilePic: user.thirdPartyUserData.picture
};
// save the settings to the database
$firebase(dataBase.child(user.uid)).$set('settings', $scope.settings);
// proceed to the next step
$scope.initialLogin = true;
// set the uid to local storage
permanentStorage.setItem('uid', user.uid);
}, function(error) {
// Ionic alert popup.
var alertPopup = $ionicPopup.alert({
title: 'Something went wrong',
template: error.message,
okType: 'button-assertive'
});
});
};
Everything is fine up to here, after saving the data to the firebase. I'm no longer able to access the data. I get this error when I try to get the data
Error: permission_denied: Client doesn't have permission to access the desired data.
at Error (native)
at dc (http://localhost:8100/js/firebase.js:44:333)
at http://localhost:8100/js/firebase.js:112:200
at http://localhost:8100/js/firebase.js:80:207
at nd.h.gc (http://localhost:8100/js/firebase.js:85:104)
at bd.gc (http://localhost:8100/js/firebase.js:76:364)
at Q.Xd (http://localhost:8100/js/firebase.js:74:280)
at Jc (http://localhost:8100/js/firebase.js:60:234)
at WebSocket.X.onmessage (http://localhost:8100/js/firebase.js:59:111)
And this one:
FIREBASE WARNING: on() or once() for /google:112071360789342135505/settings failed: Error: permission_denied: Client doesn't have permission to access the desired data.
And this is my security rules:
{
"rules": {
".write": true,
"$users": {
".read": "$users === auth.uid",
".write": "$users === auth.uid",
"settings" : {
"user" : {
"name": {
".validate": "newData.isString() && newData.val().length <= 2000"
},
"email": {
".validate": "newData.isString() && newData.val().length <= 2000"
}
}
}
}
}
}
Any thoughts on how to fix this?