Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Extra Details on Firebase User Table

I'm working on a firebase+angularjs app and I'm using the simple email and password authentication and it's working properly.

I'm just wondering if I can add extra user data on the user table which is being used by firebase email+password auth, like I want to add billing info and other details concerning the user without creating extra node/table on firebase to store these extra data.

like image 473
user3440236 Avatar asked Jun 24 '15 23:06

user3440236


People also ask

Is Firebase user UID unique?

Firebase users have a fixed set of basic properties—a unique ID, a primary email address, a name and a photo URL—stored in the project's user database, that can be updated by the user (iOS, Android, web).


1 Answers

Firebase stores the email/password users in a separate location, that you don't have direct access to. You cannot expand the data in this location.

Since many application developers want to access the user data in their application code, it is a common practice to store all users under a /users node inside the application database itself. The disadvantage is that you have to do this yourself. But the positive side of this is that you can store any extra information if you want.

See the Firebase guide on storing user data for sample code. From there:

var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com"); ref.onAuth(function(authData) {   if (authData && isNewUser) {     // save the user's profile into Firebase so we can list users,     // use them in Security and Firebase Rules, and show profiles     ref.child("users").child(authData.uid).set({       provider: authData.provider,       name: getName(authData)     });   } }); 
like image 100
Frank van Puffelen Avatar answered Oct 01 '22 01:10

Frank van Puffelen