Staff exclusions + contact-password auth sync

- contacts.password now auto-syncs to auth.users.encrypted_password via
  trg_contact_password_sync, so setting a password on the contact row in the
  Supabase UI makes it work with signInWithPassword immediately (fixes staff
  like Bruno not being able to log in with a UI-set password). One-time
  reconciliation in the migration.
- Staff excluded from the leaderboard: _sync_leaderboard skips/removes staff
  rows, get_leaderboard() filters type='staff', seed no longer inserts staff.
  Affects the attendee Leaderboard and the admin Dashboard 'Top points'.
- Home/Agenda/Profile identical for all roles: Home quick-action always
  'Scan & connect' (no 'Check-in' relabel), footer role badge removed, tab
  label always 'Scan' (staff keep check-in via the Scan screen mode toggle).
- Profile: removed the duplicate Staff pill (type pill already shows Staff).
- Agenda session sheet: 'Download material' moved to the bottom of the button
  stack with spacing.
- Docs updated (schema, rpcs, seed, screens, architecture, next-steps).
This commit is contained in:
Lago committed 2026-08-23 18:27:01 +02:00
1 parent 8b1130f078
commit 698bf13551
12 files changed
+203 -45

No files matched your search

+7 -5
View File
@@ -130,11 +130,13 @@ the work atomically, and the `leaderboard` table change fans out over Realtime.
- **Attendees & staff:** the **QR token is the Supabase Auth password**; the
**email is the identifier**. Login is a standard
`signInWithPassword({ email, password: qrToken })`.
- **APPE Admin:** logs in with **email + a real password** (event-independent, so
it works for any event). The password is recorded in `contacts.password` and
must match the bcrypt hash in `auth.users.encrypted_password`. It is set
directly in Supabase (no self-service UI). Staff can also open the admin app
with their email + QR token, since that is their Auth password.
- **APPE Admin / staff:** can log in with **email + a real password**
(event-independent, so it works for any event). The password is recorded in
`contacts.password`; a trigger (`trg_contact_password_sync`) **auto-syncs** it
as the bcrypt hash in `auth.users.encrypted_password`, so setting it in the
Supabase Table Editor makes it work with `signInWithPassword` immediately.
Staff can also still log in with their email + QR token (their seeded Auth
password).
- `enable_confirmations = false`, so **no email is sent** — the email is only a
"confirm it's you" check against the ticket purchase.
- After login, the app holds a **session JWT** (in `localStorage`) that lasts
+5 -2
View File
@@ -43,7 +43,10 @@ The single place points change. In one transaction it:
### `_sync_leaderboard(p_event_id, p_contact_email)`
Upserts the `leaderboard` row for that (event, contact) from `registrations` +
`contacts` (`on conflict (event_id, contact_email) do update ...`). This is what
makes the leaderboard a consistent, Realtime-friendly mirror.
makes the leaderboard a consistent, Realtime-friendly mirror. **Staff are
excluded:** if the contact's registration `type` is `staff` (or there is no
registration), the function **deletes** any existing leaderboard row instead of
inserting — so staff never appear on the board even if they hold points.
### `_recalc_event_aggregates(p_event_id)`
Recomputes the `events` aggregate columns (`num_sessions`, `num_speakers`,
@@ -54,7 +57,7 @@ triggers and the feedback RPC.
| Function | Returns | Used for |
|---|---|---|
| `get_leaderboard()` | `event_id, contact_email, full_name, points` (active event, ordered by points) | Leaderboard initial load + realtime re-fetch |
| `get_leaderboard()` | `event_id, contact_email, full_name, points` (active event, **staff excluded**, ordered by points) | Leaderboard initial load + realtime re-fetch |
| `lanyard_lookup(p_qr_token)` | `email, full_name, linkedin_url` (null unless `show_linkedin`), `show_email`, `registration_type` | Resolve a scanned QR (pre-login + connect) |
| `get_public_contacts()` | `email, full_name, linkedin_url`, `show_email`, `registration_type` (active-event registrants) | Connections name/type lookups |
| `get_agenda()` | flat rows: slot fields + session fields + `speakers` (string_agg) | Agenda + Home |
+5 -1
View File
@@ -56,7 +56,7 @@ password).
| `show_email` | `boolean` | default `false` — visibility toggle |
| `show_linkedin` | `boolean` | default `false` — visibility toggle |
| `is_admin` | `boolean` | default `false` — **staff = admin (merged)**; grants check-in + APPE Admin access |
| `password` | `text` | nullable — **admin-only**: the APPE Admin login password (event-independent). To work it must match the bcrypt hash in `auth.users.encrypted_password`. Set directly in Supabase (no self-service UI) |
| `password` | `text` | nullable — the **login password** (event-independent) for admin/staff. Setting it (e.g. in the Supabase Table Editor) **auto-syncs** the bcrypt hash into `auth.users.encrypted_password` via the `trg_contact_password_sync` trigger, so it works with `signInWithPassword` immediately |
| `external_id` | `text` | nullable — the Pretix order code (set by the sync) |
| `created_at` | `timestamptz` | |
@@ -247,6 +247,10 @@ truth — it is kept in sync transactionally by the RPCs (see
this table to update the leaderboard live. See
[../frontend/screens.md#leaderboard](../frontend/screens.md#leaderboard).
> **Staff are excluded.** `_sync_leaderboard` skips (and removes) staff rows, so
> staff never appear on the board even if they hold points. `get_leaderboard()`
> also filters `type = 'staff'` as defense in depth.
## `points_log` — audit trail
Powers the per-category points breakdown on the Profile screen (per event).
+7 -5
View File
@@ -15,7 +15,7 @@ Source of truth: [`supabase/seed.sql`](../../supabase/seed.sql). The seed runs o
| `slots` | 6 | 23 Oct, 09:00–15:45 (see table below) |
| `sessions` | 18 | 3 per slot (Main Stage / Room A / Room B) |
| `session_speakers` | 22 | M:N session → contact |
| `leaderboard` | 13 | mirrored from `registrations` |
| `leaderboard` | 10 | mirrored from `registrations`, **staff excluded** (13 registrants − 3 staff) |
| `points_log` | 16 | Ana's coherent breakdown + one `admin` entry per other user |
| Ana's demo state | — | 6 preferences, 2 check-ins, 4 connections, 1 feedback |
@@ -43,10 +43,12 @@ Source of truth: [`supabase/seed.sql`](../../supabase/seed.sql). The seed runs o
## Demo accounts
**Attendees & staff** log in with **QR code** (typed or scanned) + **email** —
the QR token is the Auth password. The **APPE Admin** is different: it logs in
with **email + password** (event-independent, so it works for any event). The
admin's password is stored in `contacts.password` **and** as the bcrypt hash in
`auth.users.encrypted_password` (they must match). Set it directly in Supabase.
the QR token is the Auth password. The **APPE Admin** (and any staff member you
give one) can also log in with **email + password** (event-independent, so it
works for any event). The password lives in `contacts.password`; a trigger
(`trg_contact_password_sync`) **auto-syncs** it as the bcrypt hash in
`auth.users.encrypted_password`, so just set `contacts.password` in Supabase and
it works with `signInWithPassword` immediately.
| Person | Type | Login | Email | Start pts |
|---|---|---|---|---|
+18 -11
View File
@@ -11,7 +11,7 @@ from `useAuth()` (`contact` + `registration`).
| Login | `Login.tsx` | shown when not authenticated |
| Home | `Home.tsx` | tab (default) |
| Agenda | `Agenda.tsx` | tab |
| Scan / Check-in | `Scan.tsx` | tab (role-aware label) |
| Scan | `Scan.tsx` | tab (staff get an Attendee/Staff mode toggle inside) |
| Connections | `Connections.tsx` | tab |
| Profile | `Profile.tsx` | tab |
| Leaderboard | `Leaderboard.tsx` | from Home (points pill / quick action) |
@@ -45,12 +45,14 @@ The landing screen. Shows:
- **Next card** — the pick for the next slot.
- **My picks today** — shows only **2 rows** (the current slot's pick + the next
slot's pick). "tap to change" is a **hyperlink** to the Agenda.
- **Footer type badge** — the registration-type pill is shown **only for non-
attendee** types (Attendee is the default and is not shown at the bottom).
- **Quick actions** — Scan & connect / Check-in, Agenda, Connections, Leaderboard.
- **Quick actions** — Scan & connect, Agenda, Connections, Leaderboard.
- **No active event** — a graceful empty state ("No active event right now.
Check back soon!").
> **Identical for every role.** The Home screen (and the tab bar) is the same for
> attendees and staff — no role badge, no "Check-in" relabel. Staff keep their
> check-in capability inside the **Scan** screen (Attendee/Staff mode toggle).
Data: `useEvent()` (event + agenda + clock) + `getMyPreferences()` +
`getMyCheckins(email)`. Slot status comes from `slotStatus(slot, now)`
([app-structure.md#the-event-clock](./app-structure.md#the-event-clock)).
@@ -71,8 +73,9 @@ user speaks shows a **"🎤 you"** tag; a session with material shows a **📎**
is uploaded yet, a **non-dismissible** "📎 Upload your session material" notice
with a file input. Uploading stores the file in the `materials` bucket and
calls `set_session_material` (via `uploadSessionMaterial`). Once uploaded, the
notice is gone and a **📎 Download material** link appears (visible to **all**
attendees).
notice is gone and a **📎 Download material** button appears (visible to **all**
attendees), pinned to the **bottom** of the sheet's button stack (below
"Pick this session").
- Picking is "one per slot" — picking a new session in a slot replaces the old
pick (enforced by the `set_preference` RPC).
@@ -81,9 +84,10 @@ Data: `useEvent()` + `getMyPreferences()` + `getMyCheckins(email)` +
## Scan / Check-in
One screen, two modes (segmented control: **Attendee / Staff**). The default mode
and the tab label are role-aware: staff (`contact.is_admin`) default to **Staff**
mode and the tab reads **Check-in**.
One screen, two modes (segmented control: **Attendee / Staff**). The tab label is
always **"Scan"** (the home page is identical for every role); the **default mode**
is role-aware — staff (`contact.is_admin`) default to **Staff** mode, attendees to
**Attendee** mode.
- **Attendee mode (connect):** scan a peer's lanyard → `lanyardLookup` → a
"Connect with {name}?" sheet (with the peer's registration-type badge + LinkedIn
@@ -136,6 +140,8 @@ Data: `useEvent()` (session/slot) + `submitFeedback`.
The live leaderboard.
- **Podium** for the top 3 (1st/2nd/3rd bars), then the rest as ranked rows.
- **Staff are excluded** — only attendees appear (enforced in
`get_leaderboard()` / `_sync_leaderboard`).
- **Your row is highlighted** (`me`).
- **Live:** subscribes to Realtime `postgres_changes` on the `leaderboard` table
and re-fetches on any change — so it updates the moment points change anywhere.
@@ -154,8 +160,9 @@ event). The `leaderboard` table is kept in sync transactionally by the RPCs —
## Profile
- **Header** — avatar, name, email, registration-type pill, a **staff** pill when
`contact.is_admin`, and a points pill.
- **Header** — avatar, name, email, registration-type pill, a **staff** pill
(only when `contact.is_admin` **and** the type isn't already `staff`, so it
never shows twice), and a points pill.
- **My QR code** — renders `registration.qr_token` (the token lives on the
registration, per event) as a scannable QR (`QrImage`). "Show this to staff for
check-in and to peers to connect."
+38 -3
View File
@@ -4,12 +4,15 @@ What's done, what's next, and the open decisions. The full roadmap lives in the
root [`roadmap.md`](../roadmap.md); this file is the working detail for the
current phase.
> **Current state:** Phases 0–8 are complete and verified, plus two polish
> **Current state:** Phases 0–8 are complete and verified, plus three polish
> rounds: **Fixes & Refinements** (QR token moved to the registration, role-pill
> capitalization, connection detail sheet + red-dot recalc, admin schedule
> speaker multi-select + upload/speaker bug fixes, sponsor contact search) and
> speaker multi-select + upload/speaker bug fixes, sponsor contact search),
> **Admin password + profile self-service** (admin logs in with email + password;
> attendees set LinkedIn + visibility on their Profile).
> attendees set LinkedIn + visibility on their Profile), and **Staff exclusions
> + password sync** (setting `contacts.password` auto-syncs the Auth password;
> staff excluded from the leaderboard; Home/Agenda/Profile identical for all
> roles).
> Remaining work is cross-cutting (real event clock, deployment, testing) and
> the open questions in [backend/interfaces.md](./backend/interfaces.md).
@@ -269,6 +272,38 @@ browser-verified.
`show_linkedin` is off and omits the email when `show_email` is off, so the
toggles actually control what other attendees see.
## Staff exclusions + password sync — ✅ complete
Migration `20260828000000_staff_exclusions_password_sync.sql` + app changes, all
browser-verified.
**Setting `contacts.password` now works for login.**
- A trigger (`trg_contact_password_sync`) re-hashes `contacts.password` into
`auth.users.encrypted_password` whenever it's set/changed, so entering a
password on the contact row in the Supabase Table Editor makes it work with
`signInWithPassword` immediately (previously the two had to be kept in sync
by hand). A one-time reconciliation in the migration synced any already-set
passwords.
- This is how a staff member (e.g. Bruno) can be given a password and log in.
**Staff are excluded from the leaderboard.**
- `_sync_leaderboard` skips (and removes) staff rows, so staff never appear on
the board even if they hold points. `get_leaderboard()` also filters
`type = 'staff'` (defense in depth), and the seed no longer inserts staff.
- Affects the attendee Leaderboard **and** the admin Dashboard "Top points".
**Home / Agenda / Profile are identical for every role.**
- Home: the quick-action tile is always **"Scan & connect"** (was
"Check-in" for staff) and the footer role badge is removed. The tab bar label
is always **"Scan"** (was "Check-in" for staff).
- Staff keep their check-in capability **inside the Scan screen** (the
Attendee/Staff mode toggle), so the home page stays role-agnostic.
- Profile: the duplicate **Staff** pill is gone (the registration-type pill
already shows "Staff" for staff; the extra `is_admin` pill only shows for
admins whose type isn't staff).
- Agenda session sheet: **"Download material"** moved to the **bottom** of the
button stack (below "Pick this session") with proper spacing.
## Cross-cutting / later
- **Real event clock** — replace the simulated `DEFAULT_NOW`