Pregunta

I would like to create firebase reference with user ID included. Here is my code:

var authref = new Firebase('https://myfunnyapp.firebaseio.com');
$scope.auth = $firebaseSimpleLogin(authref);

$scope.auth.$getCurrentUser().then(function(user) {
  var ref = new Firebase('https://myfunnyapp.firebaseio.com/events/' + user.id);
  $scope.events = $firebase(ref);
});

I use promise callback to resolve user when it is authentificated.

This works normaly on refresh, when I am already logged in. But after auth.$login() call user equals null.

¿Fue útil?

Solución

I found answer myself. To get response on $login call you have to give call back function to it. Like:

$scope.login = function() {
  $scope.auth.$login('facebook').then(function(user) {
    console.log(user);
  }, function(error) {
    console.error('Login failed: ', error);
  });
};
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top