I am building an admin UI for an app (in firebase/firestore) that allows supervisor admins to access their team's individual user accounts and view their dashboards / data directly. Since this is essentially identical to creating an admin for different user groups, I imagine that it can be accomplished with custom claims. The problem is that I am having trouble implementing this without weakening the firestore rules that protect our user account data or storing login credentials within the 'admin account' firestore profile doc. Could someone help me understand what I am missing here? Thank you!
This is a snippet from the current firestore rules we have in place.
match /teams/{team}{
allow create
allow read: if (request.auth.token.role == 'member' || request.auth.token.role == 'supervisor') && request.auth.token.email_verified == true
allow update, delete: if (request.auth.token.role == 'member' || request.auth.token.role == 'supervisor') && request.auth.token.email_verified == true
}
match /supervisors/{supervisor}
{
allow create
allow read: if (request.auth.token.role == 'supervisor' || request.auth.token.role == 'member') && request.auth.token.email_verified == true
allow update, delete: if request.auth.token.role == 'supervisor' && request.auth.uid == supervisor && request.auth.token.email_verified == true
}