angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

$createUser promise not returning user object

Open edwinwright opened this issue 11 years ago • 12 comments

I'm trying to create a new user, then grab the uid so that I can save additional user data during registration. I'm finding that there is no user object being returning as per the doco in https://github.com/firebase/angularfire/blob/master/src/FirebaseAuth.js.

Here is my Authentication service...

myApp.factory('Authentication',
  function($firebaseAuth, FIREBASE_URL, $location) {

  var ref = new Firebase(FIREBASE_URL);
  var authObj = $firebaseAuth(ref);

  var myObj = {
    register: function(user) {
      return authObj.$createUser(user.email, user.password)
        .then(function(authData) {

          console.log(authData); // returns undefined

        });
    },

    login: function(user) {
      return authObj.$authWithPassword({
        email: user.email,
        password: user.password
      });
    },

    logout: function() {
      return authObj.$unauth();
    }
  }

  return myObj;

});

edwinwright avatar Dec 12 '14 20:12 edwinwright

This update which returns the uid has not yet been deployed. It should be going out very soon. The official documentation is here.

jwngr avatar Dec 12 '14 23:12 jwngr

Any news on when this might be deployed?

tobysteward avatar Dec 17 '14 16:12 tobysteward

We are putting the finishing touches on 0.9.1 today. I would expect it to go out tomorrow or maybe even later today if things go well.

jwngr avatar Dec 17 '14 19:12 jwngr

Excellent! I look forward to it :)

tobysteward avatar Dec 17 '14 21:12 tobysteward

Any news on when this release will be happening?

tobysteward avatar Dec 22 '14 08:12 tobysteward

We are waiting for an upcoming release of the Firebase JS client in order to get in the new $changeEmail() method. I expected it to get released before the holidays, but that unfortunately didn't happen. Due to a lot of the team being on vacation and this not being a great time to release an update, I would expect the JS client to go out in the first week of January and AngularFire will got out right after. Thanks for your patience.

jwngr avatar Dec 26 '14 15:12 jwngr

This seems to affect both, legacy Simple Login and the new built-in Firebase Auth.

Hopefully this is going to be fixed in the next few days. This feature is rather useless without user object being returned.

pruchai avatar Jan 03 '15 18:01 pruchai

Seems fixed now.

ChrisSoto avatar Jan 09 '15 00:01 ChrisSoto

Yes, as of AngularFire 0.9.1 (which was released yesterday), the $createUser() method now returns a user object containing the uid of the created user. Please upgrade to AngularFire 0.9.1 or later if you need this functionality.

jwngr avatar Jan 09 '15 15:01 jwngr

I have still not been able to get the userData back from the $createUser method. I am using the cdn to import code into my project and I have Firebase version 2.0.4 and AngularFire 0.9.1. I have a simple controller which has the example code from the docs pretty much exactly copied and pasted. After successfully creating a user console log reports "cannot read property 'uid' of undefined"

earthcrosser avatar Jan 13 '15 20:01 earthcrosser

The user data was not exposed from the Firebase client until version 2.0.5 (here is the full changelog for the client). Just upgrade your Firebase version and you'll be all set. The latest version (which is 2.1.1 as of this comment) is fully compatible AngularFire 0.9.1 so I'd suggest upgrading to that.

jwngr avatar Jan 13 '15 21:01 jwngr

That was it, thanks jwngr! I used 2.0.5 that did it.

earthcrosser avatar Jan 13 '15 22:01 earthcrosser