Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extending Firebase Users

I am currently building a multi-platform web application and I'm currently busy with the authentication of users. I'm using vue on the client-side and django and the backend with postgres as the db.

I thought I would try out using firebase's authentication as it would speed up the process as well as take care of various issues like security etc. I have now come across a bit of a problem:

  1. I need to add extra fields the user (gender, address etc.)
  2. I need to set user roles (admin, manager etc.)

I am aware about some kind of way to set user roles but not really sure. In terms of extending the user in my mind I have two ideas:

  • Either I use the UID from firebase as a identifier to an extended user class in my backend db. But that kinda defeats the purpose of speed.
  • Use Firestore - not sure how I would go about doing this though.

plz help

like image 638
Werner Kotze Avatar asked Sep 18 '26 01:09

Werner Kotze


1 Answers

I have written a blog and made a video on how you can use custom claims to assign roles to your users. Essentially, you apply custom claims on a secure backend like inside of Cloud Functions, and these can be used to control access to Firebase backend features like Cloud Firestore and the Realtime Database. You can also check out the Firebase guide for more information.

As for additional data about a user like gender and addresses, that should be stored in Cloud Firestore, the Realtime Database, or whatever database you choose to use. It is not information that you constantly need when accessing a User object.

like image 104
Jen Person Avatar answered Sep 20 '26 09:09

Jen Person



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!