🔧 Firebase User Roles Setup Helper

Roles are stored as Firebase Auth custom claims, not Firestore documents. Use this page to assign roles by calling the assignRole Cloud Function.

📋 Step 1: Create Users in Firebase Authentication
  1. Go to Firebase Console
  2. Select your project: realtime-7fc82
  3. Navigate to Authentication → Users
  4. Click Add User and create your users (for example admin@demo.com).

After creating users, note their UIDs from the Authentication → Users list.

🔑 Step 2: Sign In as Admin

You must be signed in as an admin to call the assignRole Cloud Function. The first admin must be bootstrapped using the Firebase CLI (see note below).

⚠️ First admin bootstrap: To set the very first admin role, use the Firebase CLI:
node functions/bootstrap-admin.js <uid>
🎭 Step 3: Assign Role to User

Roles are set as custom claims on the Firebase Auth token. Valid roles: admin, user.
admin = full edit, user = limited edit, public viewers = read-only without login.

📊 Step 4: Verify Setup

After assigning a role:

🚀 Step 5: Test Your Setup
  1. Open login.html
  2. Sign in as admin and verify full create, edit, and delete access.
  3. Sign in as user and verify limited progress, status, and remarks updates work.
  4. Open the public pages without signing in and verify read-only access.
ℹ️ How roles work: Roles are stored in Firebase Auth custom claims, not Firestore. All role checks in Cloud Functions use request.auth.token.role and in client code via getIdTokenResult().