Admin password login + attendee profile self-service

- contacts.password: admin-only APPE Admin login password (event-independent);
  must match the bcrypt hash in auth.users.encrypted_password (set in Supabase).
- APPE Admin login is now email + password (was QR token).
- update_my_profile RPC (security definer, scoped to current_email()): attendees
  set their LinkedIn URL + show_email / show_linkedin toggles from the Profile.
- Convivo Profile gains a 'Profile settings' card (LinkedIn + 2 toggles + Save).
- Visibility enforced server-side in the public projection (linkedin nulled when
  show_linkedin off, email omitted when show_email off).
- Seed: admin password appe-admin-2026; staff keep QR tokens as auth passwords.
- Docs updated (schema, rpcs, seed, admin-app, screens, api-client,
  architecture, next-steps, README, docker-compose).

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:
committed 2026-08-23 14:11:26 +02:00
1 parent 2f3952dc71
commit 0221b1a8c0
19 files changed
+290 -59

No files matched your search

+8 -2
View File
@@ -127,8 +127,14 @@ the work atomically, and the `leaderboard` table change fans out over Realtime.
## 6. Authentication model
- The **QR token is the Supabase Auth password**; the **email is the identifier**.
Login is a standard `signInWithPassword({ email, password: qrToken })`.
- **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.
- `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
+14
View File
@@ -175,6 +175,20 @@ session** (the `sessions` table is admin-write only, so speakers need this
security-definer RPC to attach their uploaded material). The attendee app calls
this after uploading a file to the `materials` bucket.
### `update_my_profile(p_linkedin_url, p_show_email, p_show_linkedin)` → `contacts`
**Self-service (any authenticated attendee).** Lets a contact edit their own
profile from the Convivo app: the LinkedIn URL and the two visibility toggles
(`show_email` / `show_linkedin`).
- Scoped to `current_email()` — a user can only ever update **their own** row.
- `linkedin_url` is trimmed; an empty/blank value is stored as `NULL`.
- The toggles default to `false` when `NULL` is passed.
- **Why an RPC?** The `contacts` RLS `UPDATE` policy is **admin-only**
(`contacts_admin_update`), so an attendee cannot update their own row directly
through PostgREST. This `security definer` function (owner `postgres`) bypasses
that, but is deliberately limited to the three self-service columns — it cannot
touch `is_admin`, `password`, `external_id`, etc.
- Returns the updated contact row.
## Interface sync RPCs (service-role-only)
Two additional `security definer` RPCs import external data. They are **not**
+1
View File
@@ -56,6 +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) |
| `external_id` | `text` | nullable — the Pretix order code (set by the sync) |
| `created_at` | `timestamptz` | |
+15 -9
View File
@@ -7,7 +7,7 @@ Source of truth: [`supabase/seed.sql`](../../supabase/seed.sql). The seed runs o
| Data | Count | Notes |
|---|---|---|
| `auth.users` + `auth.identities` | 13 | 12 attendees + 1 admin; **QR token = bcrypt password** |
| `auth.users` + `auth.identities` | 13 | 12 attendees + 1 admin; **QR token = bcrypt password** (attendees/staff) — the admin uses a real **password** instead |
| `contacts` | 14 | 13 registrants + 1 external keynote speaker (no token — tokens live on registrations) |
| `events` | 1 | **APPE 2026**, 2026-10-23, São Paulo, Brazil, **active** |
| `registrations` | 13 | one per contact (Elena has none); points + **QR token** scoped here |
@@ -42,14 +42,18 @@ Source of truth: [`supabase/seed.sql`](../../supabase/seed.sql). The seed runs o
## Demo accounts
Login = **QR code** (typed or scanned) + **email**. The QR token is the password.
**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.
| Person | Type | QR code | Email | Start pts |
| Person | Type | Login | Email | Start pts |
|---|---|---|---|---|
| **Ana Silva** | attendee | `CVV-ANA-4821` | ana.silva@nubank.com | 40 |
| **Bruno Costa** | staff (admin) | `CVV-BRU-1177` | bruno.costa@acme.com | 140 |
| **Rita Lopes** | staff (admin) | `CVV-RIT-9034` | rita.lopes@globant.com | 95 |
| **APPE Admin** | staff (admin) | `CVV-ADM-0001` | admin@appe.at | 0 |
| **Ana Silva** | attendee | QR `CVV-ANA-4821` | ana.silva@nubank.com | 40 |
| **Bruno Costa** | staff (admin) | QR `CVV-BRU-1177` | bruno.costa@acme.com | 140 |
| **Rita Lopes** | staff (admin) | QR `CVV-RIT-9034` | rita.lopes@globant.com | 95 |
| **APPE Admin** | staff (admin) | **password** `appe-admin-2026` | admin@appe.at | 0 |
| Tomás Ribeiro | attendee | `CVV-TOM-5566` | tomas.ribeiro@dataprev.com | 88 |
| Sofia Almeida | attendee | `CVV-SOF-2299` | sofia.almeida@loop.com | 76 |
| Marco Chen | attendee | `CVV-MRC-7712` | marco.chen@deepmind.com | 70 |
@@ -98,5 +102,7 @@ Ana (`[email protected]`) is seeded with a coherent 40-point history:
3. Log in as **Bruno** (staff) → the Scan tab becomes **Check-in** → pick a
session → scan **Carla** (`CVV-CAR-6623`) → she gets +10.
4. Watch the **Leaderboard** update live (Realtime).
5. Log in as **APPE Admin** (`CVV-ADM-0001` / `[email protected]`) in the admin app
→ Dashboard, Contacts, Registrations, Sponsors, Schedule, Activity, Events.
5. Log in as **APPE Admin** (`[email protected]` / password `appe-admin-2026`) in the
admin app → Dashboard, Contacts, Registrations, Sponsors, Schedule, Activity,
Events. (Staff Bruno/Rita can also open the admin app with their email + QR
token, since that is their Auth password.)
+8 -5
View File
@@ -24,16 +24,19 @@ It runs on **port 3001** (Vite dev) or as the `convivo-admin` Docker container
## Auth guard
Login is the same QR + email flow as the attendee app
(`signInWithPassword({ email, password: qrToken })`), but `AuthContext` checks the
contact's `is_admin` flag after signing in:
Login is **email + password** (`signInWithPassword({ email, password })`), but
`AuthContext` checks the contact's `is_admin` flag after signing in:
- If `is_admin === true` → the session is accepted and the console is shown.
- Otherwise → the app calls `signOut()` and shows **"This account is not an
admin."** The same check runs on session restore (page reload) and on every
`onAuthStateChange`, so a non-admin can never see the console.
The demo admin is `CVV-ADM-0001` / `[email protected]`.
The password is **event-independent** — it is the contact's Auth password
(`contacts.password` must match the bcrypt hash in `auth.users.encrypted_password`),
so the same admin can log in for any event. The demo admin is
`[email protected]` / password `appe-admin-2026`. Staff (Bruno/Rita) can also open the
admin app using their email + QR token, since that is their Auth password.
## Source layout
@@ -52,7 +55,7 @@ apps/admin/src/
├─ components/
│ └─ ui.tsx # Avatar, Spinner, Empty, Modal, QrImage, TypeBadge, Toggle
├─ screens/
│ └─ Login.tsx # QR + email login (admin-only)
│ └─ Login.tsx # email + password login (admin-only)
└─ views/
├─ Dashboard.tsx # active event + aggregates + top points + activity
├─ Contacts.tsx # table + edit / is_admin / visibility / points
+1
View File
@@ -54,6 +54,7 @@ These map 1:1 to the Postgres RPCs documented in
| `submitFeedback(sessionId, rating, comment)` | `submit_feedback` | Rate a session (+5/+10) |
| `getLeaderboard()` | `get_leaderboard` | Active-event leaderboard |
| `uploadSessionMaterial(sessionId, file)` | `set_session_material` | Upload to `materials` bucket + set `material_path` |
| `updateMyProfile({linkedin_url, show_email, show_linkedin})` | `update_my_profile` | Self-service: set LinkedIn + visibility toggles on the caller's own contact |
### Direct table reads (RLS-scoped)
+9 -1
View File
@@ -159,8 +159,16 @@ event). The `leaderboard` table is kept in sync transactionally by the RPCs —
- **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."
- **Profile settings** — self-service card: a **LinkedIn** URL input plus two
**visibility toggles** ("Show my email" / "Show my LinkedIn") and a **Save
profile** button. Saving calls `update_my_profile` (the security-definer RPC,
since the `contacts` UPDATE policy is admin-only), then `refresh()` to reload
the contact. The toggles control what other attendees see — the public
projection (`lanyard_lookup` / `get_public_contacts`) nulls `linkedin_url` when
`show_linkedin` is off and omits the email when `show_email` is off.
- **Points breakdown** — sums `points_log` by category
(Session check-ins / Connections / Feedback / Other) + Total.
- **Log out** — `signOut()`.
Data: `useAuth()` (contact + registration) + `getMyPointsLog(email)`.
Data: `useAuth()` (contact + registration + `refresh`) + `getMyPointsLog(email)`
+ `updateMyProfile(...)`.
+36 -3
View File
@@ -4,10 +4,12 @@ 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 a round of
> **Fixes & Refinements** (QR token moved to the registration, role-pill
> **Current state:** Phases 0–8 are complete and verified, plus two 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).
> speaker multi-select + upload/speaker bug fixes, sponsor contact search) and
> **Admin password + profile self-service** (admin logs in with email + password;
> attendees set LinkedIn + visibility on their Profile).
> Remaining work is cross-cutting (real event clock, deployment, testing) and
> the open questions in [backend/interfaces.md](./backend/interfaces.md).
@@ -236,6 +238,37 @@ A cross-cutting polish round (migration `20260826000000_registration_qr_token.sq
- **"My picks today"** — shows only **2 rows** (current + next slot's pick);
"tap to change" is a **hyperlink** to the Agenda.
## Admin password + profile self-service — ✅ complete
Migration `20260827000000_admin_password_profile.sql` + app changes, all
browser-verified.
**APPE Admin login = email + password (event-independent).**
- `contacts.password` (admin-only) records the APPE Admin login password. To
work it must match the bcrypt hash in `auth.users.encrypted_password` — set
directly in Supabase (no self-service UI/procedure).
- The admin app's Login screen is now **Email + Password** (was QR token).
`AuthContext.signIn(email, password)` still calls `signInWithPassword` + the
`is_admin` guard.
- **Design decision:** Supabase Auth has one password per user. The dedicated
admin uses a real password (works for any event). Staff (Bruno/Rita) keep
their QR tokens as their Auth password — they can still log into the attendee
app, and can also open the admin app with email + QR token.
- Seed: the admin's password is `appe-admin-2026` (in both `contacts.password`
and `auth.users.encrypted_password`); all other contacts have `password = NULL`.
**Convivo App — Profile self-service.**
- New **Profile settings** card: a **LinkedIn** URL input + two **visibility
toggles** ("Show my email" / "Show my LinkedIn") + **Save profile**.
- Saving calls the new `update_my_profile(p_linkedin_url, p_show_email,
p_show_linkedin)` RPC (security-definer, scoped to `current_email()`, limited
to those 3 columns) — needed because the `contacts` UPDATE policy is
admin-only, so an attendee can't update their own row via PostgREST.
- Visibility is enforced **server-side**: the public projection
(`lanyard_lookup` / `get_public_contacts`) nulls `linkedin_url` when
`show_linkedin` is off and omits the email when `show_email` is off, so the
toggles actually control what other attendees see.
## Cross-cutting / later
- **Real event clock** — replace the simulated `DEFAULT_NOW`