Adding new data to firebase users

I want to add a new data to firebase authentication which has data like displayname, phone number, image. But i want to add more such gender, birthday and more. is it possible to add new?

Answers:

Answer

There is no way to add arbitrary additional data to Firebase Authentication user profiles. If you want that, consider using the Firebase Realtime Database (or Cloud Firestore) for storing the additional information.

This approach has been covered in quite a few questions in the past, so I'll link you to those:

Since a few weeks ago you can add small bits of information to the Firebase Authentication user profile. While this might sound like what you need, it is explicitly not meant for storing user metadata such as you need. Instead this is intended for storing so-called claims: properties about the user that you then access in the security rules. See the documentation for setting custom claims.

Answer

I had the same problem when introducing user roles for authorization in my React with Firebase application. Somehow I wanted to be able to pass a roles property to the authenticated user, but found myself again in Firebase's restrictive framework of doing it their way.

I found a way around it by (1) managing users myself in the Firebase database and (2) merging the authenticated user with the database user when the application loads. Then I am able to add additional user properties (e.g. roles) to my database user, because it will be merged with the authenticated user anyway.

If you are interested in this approach, checkout this tutorial.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.