I'm using Firebase as my main backend solution and have created a service for dealing with auth throughout the app (since I started to use simpleLogin and now I'm trying to use their built in login methods, I figured it might be better to just make all that scoped before accessing it from the rest of the application).
My firebase reference is working fine and so it is the auth methods.
But the listening methods onAuth() and offAuth() are throwing this error:
Uncaught TypeError: Cannot read property 'auth' of undefined - firebase-debug.js:9954
Is this a bug with firebase itself or does anyone see something I'm doing wrong? Tried to play around with angular versions and turning off other bower packages like angularfire and firebase-simple-login but have had no success so far.
My auth service code is as follows and I'm not doing anything beyond defining my url on a .constant service.
angular.module('myApp')
.factory('auth', function (firebaseAPIUrl) {
var ref = new Firebase(firebaseAPIUrl),
onAuth = ref.onAuth,
offAuth = ref.offAuth;
onAuth(function (authData) {
console.log(authData);
});
function getCurrentUser() {
return ref.getAuth();
}
...
return {
onAuth: onAuth,
offAuth: offAuth,
getCurrentUser: getCurrentUser,
...
}
}
onAuth,offAuth, etc., what happens when you try returningonAuth.bind(ref), etc.? Also, which version of the Firebase web client is included in your application? - Rob DiMarcovar onAuth = ref.onAuth.bind(ref);is that it? - Georges BorisonAuth = ref.onAuth.bind(ref), etc. it works perfectly. But I haven't found anything about this on the docs. Can you elaborate on this matter as a response so I can accept it? Thanks! - Georges Boris