I am developing a platform using Vite + React, Firebase Authentication where users (teachers and students) sign in using Google authentication. I need to implement role-based access control (RBAC) to differentiate between:
Teachers, who have administrative privileges. Students, who have restricted access. Admin, who have some more privileges and keep a check on website
What I Need Help With:
As Firebase Authentication does not natively support roles, you need to store user roles separately. The best approach is to use Firestore
or Realtime Database to manage user roles.
users
collection in Firestore
with each user's uid
, email
, and role
.Firestore
when they log in and store it in the app state.Check this documentation for more information.