Phase 2: Admin console (admin.appe.at)
A desktop-first React app for organizers, guarded to the admin role. Backend (supabase/migrations/20260823000000_admin_app.sql): - Admin-only SELECT policies on preferences, connections, feedback - reset_qr_token RPC: regenerates a lanyard token, re-hashes it as the Auth password (old token stops working), and clears the attendee's sessions to force re-login App (apps/admin, port 3001): - Login: same QR+email flow, but non-admin sessions are rejected - Dashboard: live stats + top points + recent activity - Attendees: search, edit name/company/role, reset QR, adjust points - Schedule: manage slots + sessions (create/edit/delete) - Activity: check-ins / connections / feedback tables - Same-origin proxy (Vite dev / nginx in Docker), same design tokens Docker + scripts: - convivo-admin service in docker-compose.yml (:3001) - admin:dev / admin:build root scripts - fixed db:reset script (supabase reset -> supabase db reset) Docs: new frontend/admin-app.md; updated architecture, rls, rpcs, docker, next-steps, and READMEs. Verified: build clean, all views + flows browser-tested, Docker build + proxy + login + admin guard confirmed. DB reset to clean seed. Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
1 parent
015c0a3a06
commit
32c86767ef
45 files changed
+4425
-87
No files matched your search
+18
-6
@@ -37,13 +37,18 @@ Two `security definer` functions drive role checks (see [rpcs.md](./rpcs.md#role
|
||||
| `profiles` | own **or** admin | — | admin only | admin only |
|
||||
| `slots` | all authenticated | admin only | admin only | admin only |
|
||||
| `sessions` | all authenticated | admin only | admin only | admin only |
|
||||
| `preferences` | own (`profile_id = auth.uid()`) | — | — | — |
|
||||
| `connections` | rows you're in (`from_id` or `to_id` = you) | — | — | — |
|
||||
| `preferences` | own **or** admin | — | — | — |
|
||||
| `connections` | rows you're in **or** admin | — | — | — |
|
||||
| `checkins` | own **or** staff/admin | — | — | — |
|
||||
| `feedback` | own | — | — | — |
|
||||
| `feedback` | own **or** admin | — | — | — |
|
||||
| `leaderboard` | all authenticated | — | — | — |
|
||||
| `points_log` | own **or** admin | — | — | — |
|
||||
|
||||
> **Phase 2 addition** ([`20260823000000_admin_app.sql`](../../supabase/migrations/20260823000000_admin_app.sql)):
|
||||
> admin-only `select` policies were added to `preferences`, `connections`, and
|
||||
> `feedback` so the Admin console can read the full activity. The per-user
|
||||
> policies above are unchanged — these are additive `OR is_admin()` reads.
|
||||
|
||||
**"—" (no policy)** means normal users have **no direct write access** — those
|
||||
tables are written only by the `security definer` RPCs, which bypass RLS. This is
|
||||
deliberate: a client cannot `UPDATE profiles SET points = 9999` or insert its own
|
||||
@@ -89,6 +94,12 @@ create policy "leaderboard_select_all" on public.leaderboard for select to authe
|
||||
-- points_log: read own or admin
|
||||
create policy "points_log_select_own_or_admin" on public.points_log for select to authenticated
|
||||
using (profile_id = auth.uid() or public.is_admin());
|
||||
|
||||
-- Phase 2 (20260823000000_admin_app.sql): additive admin-only reads for the
|
||||
-- Admin console. These OR with the per-user policies above.
|
||||
create policy "prefs_select_admin" on public.preferences for select to authenticated using (public.is_admin());
|
||||
create policy "conn_select_admin" on public.connections for select to authenticated using (public.is_admin());
|
||||
create policy "feedback_select_admin" on public.feedback for select to authenticated using (public.is_admin());
|
||||
```
|
||||
|
||||
## GRANTs
|
||||
@@ -113,9 +124,10 @@ full DML at the Postgres level, but **RLS narrows it** to the policies above.
|
||||
internally, e.g. only staff can call `checkin_attendee`).
|
||||
- **Staff** — everything an attendee can do, plus can read all `checkins` and call
|
||||
the check-in RPC.
|
||||
- **Admin** — full read on everything, and the only role with **direct** write
|
||||
access to `profiles` / `slots` / `sessions` (this is what the future Admin app
|
||||
in Phase 2 will use).
|
||||
- **Admin** — full read on everything (including all `preferences`,
|
||||
`connections`, and `feedback`), and the only role with **direct** write access
|
||||
to `profiles` / `slots` / `sessions`. This is exactly what the Admin console
|
||||
(Phase 2, [`../frontend/admin-app.md`](../frontend/admin-app.md)) uses.
|
||||
|
||||
## Things to revisit later
|
||||
|
||||
|
||||
Reference in new issue
Block a user