DEV Community

Discussion on: To the Stars with Quasar & Firebase - User Profile

Collapse
 
gicelte profile image
gicelte

Hi, thanks for the great article! I am interested in implementing role-based authentication with Firebase. Could you give some hints about how to extend the code you have provided to get a system able to manage administrators and normal users? Is this related to David's question below?

Collapse
 
adamkpurdy profile image
Adam Purdy

Hey @gicelte you need to implement the setCustomUserClaims on the server side of things via Firebase Admin.

On my service side of things in my applications I just add a simple prop in the method call.

await admin.auth().setCustomUserClaims(authUser.uid, {
  isAdmin: true
})
Enter fullscreen mode Exit fullscreen mode

Then will do an await call on the client to route the user based on perms set on the user's auth record coming back from Firebase auth.

This is a start but by no means a thorough approach as user roles can be extensive in an application. For an in-depth setup explanation of setCustomUserClaims try googling: 'role based auth with firebase admin tutorial'.

Hope that gave you enough to point you in the right direction.