Staff Dashboard Setup Guide
Quick start guide for setting up and using the staff dashboard.
โ Prerequisites Completed
- Clerk JWT template configured with
staffDashboardAccessclaim - Convex schema deployed with staff tables
- Security infrastructure in place (4 layers)
- Basic UI routes created
๐ Quick Start
1. Grant Staff Access to First Admin
Run this script to grant staff access to a @do.dev user:
pnpm tsx scripts/grant-staff-access.ts your-email@do.devRequirements:
- User must already be signed up in Clerk
- Email must end with @do.dev
- CLERK_SECRET_KEY must be set in .env.local
2. Sign Out and Sign Back In
After granting access, the user needs to:
- Sign out completely
- Sign back in
- This refreshes the JWT token with the new
staffDashboardAccessclaim
3. Access the Staff Dashboard
Navigate to:
http://localhost:3017/staffYou should see the staff dashboard with:
- โ Warning banner
- โ Navigation sidebar
- โ Dashboard overview with placeholder cards
- โ Quick actions
๐ Security Verification
Test Unauthorized Access
-
Test with no auth:
- Navigate to
/staffwithout being logged in - Should redirect to sign-in page
- Navigate to
-
Test with wrong email domain:
- Sign in with a non-@do.dev email
- Navigate to
/staff - Should show 404 (hiding dashboard existence)
-
Test without staff flag:
- Sign in with @do.dev email but no
staffDashboardAccess - Navigate to
/staff - Should show 404
- Sign in with @do.dev email but no
-
Test with full access:
- Sign in with @do.dev email +
staffDashboardAccess = true - Navigate to
/staff - Should see staff dashboard โ
- Sign in with @do.dev email +
๐ Current Features
โ Implemented (Phase 1 & 2)
-
Security Infrastructure
- 4-layer defense in depth
- Middleware protection
- Layout server-side checks
- Convex function auth helpers
-
Basic UI
- Dashboard overview page
- User management page (placeholder)
- Audit logs page (placeholder)
- Navigation sidebar
-
Database Schema
staffAuditLogstableuserProfilestable
โณ Coming Soon (Phase 3 & 4)
-
Dashboard Stats (Phase 3)
- Real user counts from Clerk
- Active user metrics
- Staff member count
- Recent activity feed
-
User Management (Phase 3)
- List all Clerk users
- Search and filter
- Grant/revoke staff access
- View user details
- Add staff notes
-
Audit Logs (Phase 4)
- View all staff actions
- Filter by staff member, action, date
- Export audit reports
๐งช Testing Checklist
- Can access
/staffwith authorized user - Cannot access
/staffwithout auth - Cannot access
/staffwith wrong email domain - Cannot access
/staffwithout staff flag - Navigation works between pages
- User info displays correctly in sidebar
- Warning banner appears on all pages
๐ง Troubleshooting
"404 Not Found" when accessing /staff
Possible causes:
- User not authenticated โ Sign in first
- Email domain not @do.dev โ Check your email
- Staff access not granted โ Run grant script
- JWT claim not updated โ Sign out and back in
Solution:
# Grant access
pnpm tsx scripts/grant-staff-access.ts your-email@do.dev
# Sign out completely, then sign back in"Middleware errors"
Check that:
- Clerk credentials are in .env.local
- Convex is running (
pnpm dev:convex) - No typos in email domain check
"Can't find user"
Make sure the user has signed up at least once before granting staff access.
๐ Next Steps
-
Deploy Convex Schema:
pnpm convex:deploy -
Grant Staff Access:
pnpm tsx scripts/grant-staff-access.ts admin@do.dev -
Test Access:
- Sign out and back in
- Navigate to http://localhost:3017/staff
- Verify you can see the dashboard
-
Ready for Phase 3:
- Implement real dashboard stats
- Build user management features
- Connect to Convex queries
๐ฏ Development Phases
- โ Phase 1: Security foundation (COMPLETE)
- โ Phase 2: Route protection & basic UI (COMPLETE)
- โณ Phase 3: Real data integration (Next)
- โณ Phase 4: Advanced features
- โณ Phase 5: Security hardening & polish
๐ Getting Help
Refer to the main plan document for detailed architecture:
docs/STAFF_DASHBOARD_PLAN.mdCheck the source code comments for implementation details:
lib/auth/staff-auth.ts- Authorization utilitiesconvex/_helpers/staffAuth.ts- Convex auth helpersmiddleware.ts- Route protectionapp/staff/layout.tsx- Dashboard layout