Firebase / AngularFire create user information

angularfire, firebase

Solution

You can't. Firebase hides the complexity of login management by storing the login details in its own datastore. This process knows nothing of your app's forge, which means it doesn't know if or where you're storing any additional user information. It returns the data that it does know about as a convenience (id, uid, email, md5_hash, provider, firebaseAuthToken).

It's up to your app to then take the [u]id and grab whatever app specific user information you need (such as first name, last name). For an Angular app, you'd want to have a UserProfile service which retrieves the data you're looking for once you get the authentication success broadcast.

Also, in your snippet, consider changing

.child(user.id) 

to

.child(user.uid) 

This will come in handy if you ever support Facebook/Twitter/Persona authentication later on. uid looks like "simplelogin:1" - it helps to avoid unlikely but possible id clashes across providers.

Problem

I'm creating a new user with AngularFire. But when I sign the user up I also ask for first name and last name and I add that info after registration. ``` $firebaseSimpleLogin(fbRef).$createUser($scope.signupData.email, $scope.signupData.password).then(function (user) { // Add additional information for current user $firebase(fbRef.child('users').child(user.id).child("name")).$set({ first: $scope.signupData.first_name, last: $scope.signupData.last_name }).then(function () { $rootScope.user = user; }); }); ``` The above code works, it creates node fin Firebase (users/user.id/ ...). The problem When I login with the new user I get the user default information: id, email, uid, etc. but no name. How can I associate that data automatically to the user?

Original source