Firebase createUser () doesn't return id of created user

I am using Firebase 1.1 (which embeds the old firebase-simple-login functionality).

Now, when creating a user, how do I get its id (or uid)?

app.controller('AuthCtrl', function ($scope, $firebase) {
  var ref = new Firebase(MY_FIREBASE_URL);
  ref.createUser({
    email: 'mary@mail.com',
    password: 'her-super-secret-password'
  },
  function(err) {
    switch (err.code) {
      ...
    }
  }
}

      

As I understand it, the function createUser

callback only reports the object err

in case of an error. But - if successful - I need the generated user id (or better uid) in order to use it to add the user to my internal user profiles ...

How do I create a User ID from Firebase createUser

?

UPDATE : I just ditched 1.1 back to 1.0 until other docs appear (or some kind of response I get ...): --(

+3


source to share


1 answer


Firebase recently released an updated JavaScript client (v2.0.5) that directly exposes the user id of the newly created user via the second argument to the completion callback.

Check the changelog https://www.firebase.com/docs/web/changelog.html and look below:



ref.createUser({
  email: '...',
  password: '...'
}, function(err, user) {
  if (!err) {
    console.log('User created with id', user.uid);
  }
});

      

+4


source







All Articles