Search code examples
firebasegoogle-cloud-platformfirebase-authenticationgoogle-cloud-functions

How to add custom claim admin role to a user on firebase


How do I create an admin account profile on Firebase to login to the same interface on my app app. I can't find the option of making a user an admin on Firebase.


Solution

  • There are 2 ways of achieving this, as far as I can think of the problem right now.

    • Setting a Custom Claim through the backend, through Firebase Functions, and then reading the custom claim value in the frontend through Firebase Authentication. (process goes through a paid Firebase Plan)
    • The second part would be much simpler. In this case, let's say you do not want to enter into a paid Firebase plan, what you can do is make a variable or entry named admin or is_admin in the Firebase Realtime Database or Firebase Firestore wherever you are storing your account profile. Now whenever the value is set to true you can enable the adminprivileges else remove the privileges.