Reputation: 17721
I'm using Firebase 1.1 (which embeds old firebase-simple-login functionalities).
Now, when creating a user, how do I get it's id (or uid)?
app.controller('AuthCtrl', function ($scope, $firebase) {
var ref = new Firebase(MY_FIREBASE_URL);
ref.createUser({
email: '[email protected]',
password: 'her-super-secret-password'
},
function(err) {
switch (err.code) {
...
}
}
}
As far as I can understand, createUser
function callback only reports an err
object in case of error. But - in case of success - I need the created user id (or better uid), to use it to add the user to my internal users profiles...
How do I get created user id from Firebase createUser
?
UPDATE: I did just give up with 1.1, reverting to 1.0 until some more docs are available (or some answer I get...) :-(
Upvotes: 3
Views: 1709
Reputation: 1695
Firebase recently released an updated JavaScript client (v2.0.5) which directly exposes the user id of the newly-created user via the second argument to the completion callback.
Check out the changelog at https://www.firebase.com/docs/web/changelog.html and see below for an example:
ref.createUser({
email: '...',
password: '...'
}, function(err, user) {
if (!err) {
console.log('User created with id', user.uid);
}
});
Upvotes: 4