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).
This commit is contained in:
Lago committed 2026-08-23 14:11:26 +02:00
1 parent b52d8ab007
commit 8b1130f078
19 files changed
+290 -59

No files matched your search

+9 -7
View File
@@ -280,14 +280,16 @@ Open **http://localhost:3000** (attendee) and **http://localhost:3001** (admin).
## 12. Demo accounts ## 12. 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 password. The **APPE Admin** logs in with **email + password**
(event-independent).
| Person | Role | QR code | Email | | Person | Role | Login | Email |
|---|---|---|---| |---|---|---|---|
| **Ana Silva** | attendee | `CVV-ANA-4821` | ana.silva@nubank.com | | **Ana Silva** | attendee | QR `CVV-ANA-4821` | ana.silva@nubank.com |
| **Bruno Costa** | staff | `CVV-BRU-1177` | bruno.costa@acme.com | | **Bruno Costa** | staff | QR `CVV-BRU-1177` | bruno.costa@acme.com |
| **Rita Lopes** | staff | `CVV-RIT-9034` | rita.lopes@globant.com | | **Rita Lopes** | staff | QR `CVV-RIT-9034` | rita.lopes@globant.com |
| **APPE Admin** | admin | `CVV-ADM-0001` | admin@appe.at | | **APPE Admin** | admin | **password** `appe-admin-2026` | admin@appe.at |
| Tomás Ribeiro | attendee | `CVV-TOM-5566` | tomas.ribeiro@dataprev.com | | Tomás Ribeiro | attendee | `CVV-TOM-5566` | tomas.ribeiro@dataprev.com |
| Sofia Almeida | attendee | `CVV-SOF-2299` | sofia.almeida@loop.com | | Sofia Almeida | attendee | `CVV-SOF-2299` | sofia.almeida@loop.com |
| Marco Chen | attendee | `CVV-MRC-7712` | marco.chen@deepmind.com | | Marco Chen | attendee | `CVV-MRC-7712` | marco.chen@deepmind.com |
@@ -303,7 +305,7 @@ Login = **QR code** (typed or scanned) + **email**. The QR token is the password
2. Scan **Marco** (`CVV-MRC-7712`) → send a connection request. 2. Scan **Marco** (`CVV-MRC-7712`) → send a connection request.
3. Log in as **Bruno** (staff) → the Scan tab becomes **Check-in** → pick a session → scan **Carla** (`CVV-CAR-6623`) → she gets +10. 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. 4. Watch the **Leaderboard** update live.
5. Open the **APPE Admin** console on **:3001** → log in as **APPE Admin** (`CVV-ADM-0001` / admin@appe.at) → see the Dashboard, reset a contact's QR, adjust points, and edit the schedule. 5. Open the **APPE Admin** console on **:3001** → log in as **APPE Admin** (`[email protected]` / password `appe-admin-2026`) → see the Dashboard, reset a contact's QR, adjust points, and edit the schedule.
## 13. Roadmap ## 13. Roadmap
+4 -3
View File
@@ -5,7 +5,8 @@ import type { Contact } from '../lib/types';
interface AuthState { interface AuthState {
contact: Contact | null; contact: Contact | null;
loading: boolean; loading: boolean;
signIn: (email: string, qrToken: string) => Promise<void>; /** Sign in with the admin's email + password (event-independent). */
signIn: (email: string, password: string) => Promise<void>;
signOut: () => Promise<void>; signOut: () => Promise<void>;
} }
@@ -72,10 +73,10 @@ export function AuthProvider({ children }: { children: ReactNode }) {
}; };
}, []); }, []);
async function signIn(email: string, qrToken: string) { async function signIn(email: string, password: string) {
const { data, error } = await supabase.auth.signInWithPassword({ const { data, error } = await supabase.auth.signInWithPassword({
email, email,
password: qrToken, password,
}); });
if (error) throw new Error(error.message); if (error) throw new Error(error.message);
+2
View File
@@ -19,6 +19,8 @@ export interface Contact {
show_email: boolean; show_email: boolean;
show_linkedin: boolean; show_linkedin: boolean;
is_admin: boolean; is_admin: boolean;
/** Admin-only: the APPE Admin login password (event-independent). */
password: string | null;
created_at: string; created_at: string;
} }
+10 -9
View File
@@ -6,17 +6,17 @@ export function Login() {
const { signIn } = useAuth(); const { signIn } = useAuth();
const { push } = useToast(); const { push } = useToast();
const [email, setEmail] = useState(''); const [email, setEmail] = useState('');
const [token, setToken] = useState(''); const [password, setPassword] = useState('');
const [busy, setBusy] = useState(false); const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
async function onSubmit(e: FormEvent) { async function onSubmit(e: FormEvent) {
e.preventDefault(); e.preventDefault();
if (!email.trim() || !token.trim()) return; if (!email.trim() || !password.trim()) return;
setBusy(true); setBusy(true);
setError(null); setError(null);
try { try {
await signIn(email.trim(), token.trim().toUpperCase()); await signIn(email.trim(), password);
push('success', 'Welcome back'); push('success', 'Welcome back');
} catch (err) { } catch (err) {
const msg = err instanceof Error ? err.message : 'Sign in failed'; const msg = err instanceof Error ? err.message : 'Sign in failed';
@@ -34,7 +34,7 @@ export function Login() {
<div className="logo"><img src="/icon-192.png" alt="APPE" /></div> <div className="logo"><img src="/icon-192.png" alt="APPE" /></div>
<div> <div>
<h1>APPE Admin</h1> <h1>APPE Admin</h1>
<p>Sign in with your admin QR token and email.</p> <p>Sign in with your admin email and password.</p>
</div> </div>
</div> </div>
<form className="login-form" onSubmit={onSubmit}> <form className="login-form" onSubmit={onSubmit}>
@@ -51,12 +51,13 @@ export function Login() {
/> />
</div> </div>
<div className="field"> <div className="field">
<label>QR token</label> <label>Password</label>
<input <input
className="input mono" className="input"
placeholder="CVV-ADM-0001" type="password"
value={token} placeholder="••••••••••"
onChange={(e) => setToken(e.target.value)} value={password}
onChange={(e) => setPassword(e.target.value)}
autoComplete="current-password" autoComplete="current-password"
required required
/> />
+21
View File
@@ -48,6 +48,27 @@ export function Sheet({ open, onClose, children }: { open: boolean; onClose: ()
); );
} }
/** A small on/off switch with a label. */
export function Toggle({
checked,
onChange,
label,
}: {
checked: boolean;
onChange: (v: boolean) => void;
label: string;
}) {
return (
<label className="toggle">
<input type="checkbox" checked={checked} onChange={(e) => onChange(e.target.checked)} />
<span className="track">
<span className="knob" />
</span>
<span className="toggle-lbl">{label}</span>
</label>
);
}
/** Render a string (e.g. a QR token) as a scannable QR code. */ /** Render a string (e.g. a QR token) as a scannable QR code. */
export function QrImage({ value, size = 180 }: { value: string; size?: number }) { export function QrImage({ value, size = 180 }: { value: string; size?: number }) {
return ( return (
+13
View File
@@ -93,6 +93,19 @@ export async function getMyRegistration(email: string): Promise<Registration | n
return (data as Registration) ?? null; return (data as Registration) ?? null;
} }
/** Update the caller's own profile: LinkedIn URL + visibility toggles. */
export async function updateMyProfile(input: {
linkedin_url: string | null;
show_email: boolean;
show_linkedin: boolean;
}): Promise<Contact> {
return rpc<Contact>('update_my_profile', {
p_linkedin_url: input.linkedin_url,
p_show_email: input.show_email,
p_show_linkedin: input.show_linkedin,
});
}
export async function getActiveEvent(): Promise<Event | null> { export async function getActiveEvent(): Promise<Event | null> {
const { data, error } = await supabase.from('events').select('*').eq('is_active', true).maybeSingle(); const { data, error } = await supabase.from('events').select('*').eq('is_active', true).maybeSingle();
if (error) throw new ApiError(error.message); if (error) throw new ApiError(error.message);
+52 -3
View File
@@ -1,9 +1,10 @@
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { useAuth } from '../context/AuthContext'; import { useAuth } from '../context/AuthContext';
import { getMyPointsLog } from '../lib/api'; import { getMyPointsLog, updateMyProfile } from '../lib/api';
import { capWords } from '../lib/time'; import { capWords } from '../lib/time';
import type { PointsLogRow } from '../lib/types'; import type { PointsLogRow } from '../lib/types';
import { Avatar, QrImage, Spinner } from '../components/ui'; import { Avatar, QrImage, Spinner, Toggle } from '../components/ui';
import { useToast } from '../context/ToastContext';
const CATEGORY_LABEL: Record<PointsLogRow['category'], string> = { const CATEGORY_LABEL: Record<PointsLogRow['category'], string> = {
checkin: 'Session check-ins', checkin: 'Session check-ins',
@@ -13,10 +14,17 @@ const CATEGORY_LABEL: Record<PointsLogRow['category'], string> = {
}; };
export function Profile() { export function Profile() {
const { contact, registration, signOut } = useAuth(); const { contact, registration, signOut, refresh } = useAuth();
const { toast } = useToast();
const [log, setLog] = useState<PointsLogRow[]>([]); const [log, setLog] = useState<PointsLogRow[]>([]);
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
// Profile self-service (LinkedIn + visibility).
const [linkedin, setLinkedin] = useState(contact?.linkedin_url ?? '');
const [showEmail, setShowEmail] = useState(contact?.show_email ?? false);
const [showLinkedin, setShowLinkedin] = useState(contact?.show_linkedin ?? false);
const [saving, setSaving] = useState(false);
const email = contact?.email ?? ''; const email = contact?.email ?? '';
useEffect(() => { useEffect(() => {
@@ -42,6 +50,23 @@ export function Profile() {
const totals: Record<string, number> = {}; const totals: Record<string, number> = {};
for (const l of log) totals[l.category] = (totals[l.category] ?? 0) + l.delta; for (const l of log) totals[l.category] = (totals[l.category] ?? 0) + l.delta;
async function saveProfile() {
setSaving(true);
try {
await updateMyProfile({
linkedin_url: linkedin.trim() || null,
show_email: showEmail,
show_linkedin: showLinkedin,
});
await refresh();
toast('Profile updated', 'ok');
} catch (e) {
toast(e instanceof Error ? e.message : 'Could not save profile', 'err');
} finally {
setSaving(false);
}
}
return ( return (
<section className="screen"> <section className="screen">
<div className="h1">Profile</div> <div className="h1">Profile</div>
@@ -68,6 +93,30 @@ export function Profile() {
</div> </div>
</div> </div>
<div className="card">
<div className="h2" style={{ marginBottom: 6 }}>Profile settings</div>
<div className="muted small" style={{ marginBottom: 12 }}>
Choose what other attendees can see on your profile.
</div>
<div style={{ marginBottom: 12 }}>
<div className="muted small" style={{ marginBottom: 4 }}>LinkedIn</div>
<input
className="input"
type="url"
placeholder="https://linkedin.com/in/you"
value={linkedin}
onChange={(e) => setLinkedin(e.target.value)}
/>
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 10, marginBottom: 14 }}>
<Toggle checked={showEmail} onChange={setShowEmail} label="Show my email" />
<Toggle checked={showLinkedin} onChange={setShowLinkedin} label="Show my LinkedIn" />
</div>
<button className="btn primary" disabled={saving} onClick={() => void saveProfile()}>
{saving ? 'Saving…' : 'Save profile'}
</button>
</div>
<div className="card"> <div className="card">
<div className="h2" style={{ marginBottom: 6 }}>Points breakdown</div> <div className="h2" style={{ marginBottom: 6 }}>Points breakdown</div>
{loading ? ( {loading ? (
+14
View File
@@ -88,6 +88,20 @@ body {
.input:focus { border-color: var(--accent); } .input:focus { border-color: var(--accent); }
textarea.input { resize: none; min-height: 96px; } textarea.input { resize: none; min-height: 96px; }
.divider { height: 1px; background: var(--line); margin: 4px 0; } .divider { height: 1px; background: var(--line); margin: 4px 0; }
/* toggle switch */
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track {
width: 42px; height: 24px; border-radius: 999px; background: var(--line);
position: relative; transition: background .15s; flex-shrink: 0;
}
.toggle .knob {
position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s;
}
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track .knob { transform: translateX(18px); }
.toggle-lbl { font-size: 14px; font-weight: 600; }
/* ---------- Tab bar ---------- */ /* ---------- Tab bar ---------- */
.tabbar { .tabbar {
+1 -1
View File
@@ -20,7 +20,7 @@
# - http://localhost:3000 (attendee app) — log in with a demo QR code # - http://localhost:3000 (attendee app) — log in with a demo QR code
# (e.g. CVV-ANA-4821 / [email protected]) # (e.g. CVV-ANA-4821 / [email protected])
# - http://localhost:3001 (admin app) — log in as admin # - http://localhost:3001 (admin app) — log in as admin
# (CVV-ADM-0001 / [email protected]) # ([email protected] / password appe-admin-2026)
name: convivo name: convivo
+8 -2
View File
@@ -127,8 +127,14 @@ the work atomically, and the `leaderboard` table change fans out over Realtime.
## 6. Authentication model ## 6. Authentication model
- The **QR token is the Supabase Auth password**; the **email is the identifier**. - **Attendees & staff:** the **QR token is the Supabase Auth password**; the
Login is a standard `signInWithPassword({ email, password: qrToken })`. **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 - `enable_confirmations = false`, so **no email is sent** — the email is only a
"confirm it's you" check against the ticket purchase. "confirm it's you" check against the ticket purchase.
- After login, the app holds a **session JWT** (in `localStorage`) that lasts - 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 security-definer RPC to attach their uploaded material). The attendee app calls
this after uploading a file to the `materials` bucket. 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) ## Interface sync RPCs (service-role-only)
Two additional `security definer` RPCs import external data. They are **not** 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_email` | `boolean` | default `false` — visibility toggle |
| `show_linkedin` | `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 | | `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) | | `external_id` | `text` | nullable — the Pretix order code (set by the sync) |
| `created_at` | `timestamptz` | | | `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 | | 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) | | `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** | | `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 | | `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 ## 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 | | **Ana Silva** | attendee | QR `CVV-ANA-4821` | ana.silva@nubank.com | 40 |
| **Bruno Costa** | staff (admin) | `CVV-BRU-1177` | bruno.costa@acme.com | 140 | | **Bruno Costa** | staff (admin) | QR `CVV-BRU-1177` | bruno.costa@acme.com | 140 |
| **Rita Lopes** | staff (admin) | `CVV-RIT-9034` | rita.lopes@globant.com | 95 | | **Rita Lopes** | staff (admin) | QR `CVV-RIT-9034` | rita.lopes@globant.com | 95 |
| **APPE Admin** | staff (admin) | `CVV-ADM-0001` | admin@appe.at | 0 | | **APPE Admin** | staff (admin) | **password** `appe-admin-2026` | admin@appe.at | 0 |
| Tomás Ribeiro | attendee | `CVV-TOM-5566` | tomas.ribeiro@dataprev.com | 88 | | Tomás Ribeiro | attendee | `CVV-TOM-5566` | tomas.ribeiro@dataprev.com | 88 |
| Sofia Almeida | attendee | `CVV-SOF-2299` | sofia.almeida@loop.com | 76 | | Sofia Almeida | attendee | `CVV-SOF-2299` | sofia.almeida@loop.com | 76 |
| Marco Chen | attendee | `CVV-MRC-7712` | marco.chen@deepmind.com | 70 | | 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 3. Log in as **Bruno** (staff) → the Scan tab becomes **Check-in** → pick a
session → scan **Carla** (`CVV-CAR-6623`) → she gets +10. session → scan **Carla** (`CVV-CAR-6623`) → she gets +10.
4. Watch the **Leaderboard** update live (Realtime). 4. Watch the **Leaderboard** update live (Realtime).
5. Log in as **APPE Admin** (`CVV-ADM-0001` / `[email protected]`) in the admin app 5. Log in as **APPE Admin** (`[email protected]` / password `appe-admin-2026`) in the
→ Dashboard, Contacts, Registrations, Sponsors, Schedule, Activity, Events. 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 ## Auth guard
Login is the same QR + email flow as the attendee app Login is **email + password** (`signInWithPassword({ email, password })`), but
(`signInWithPassword({ email, password: qrToken })`), but `AuthContext` checks the `AuthContext` checks the contact's `is_admin` flag after signing in:
contact's `is_admin` flag after signing in:
- If `is_admin === true` → the session is accepted and the console is shown. - 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 - 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 admin."** The same check runs on session restore (page reload) and on every
`onAuthStateChange`, so a non-admin can never see the console. `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 ## Source layout
@@ -52,7 +55,7 @@ apps/admin/src/
├─ components/ ├─ components/
│ └─ ui.tsx # Avatar, Spinner, Empty, Modal, QrImage, TypeBadge, Toggle │ └─ ui.tsx # Avatar, Spinner, Empty, Modal, QrImage, TypeBadge, Toggle
├─ screens/ ├─ screens/
│ └─ Login.tsx # QR + email login (admin-only) │ └─ Login.tsx # email + password login (admin-only)
└─ views/ └─ views/
├─ Dashboard.tsx # active event + aggregates + top points + activity ├─ Dashboard.tsx # active event + aggregates + top points + activity
├─ Contacts.tsx # table + edit / is_admin / visibility / points ├─ 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) | | `submitFeedback(sessionId, rating, comment)` | `submit_feedback` | Rate a session (+5/+10) |
| `getLeaderboard()` | `get_leaderboard` | Active-event leaderboard | | `getLeaderboard()` | `get_leaderboard` | Active-event leaderboard |
| `uploadSessionMaterial(sessionId, file)` | `set_session_material` | Upload to `materials` bucket + set `material_path` | | `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) ### 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 - **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 registration, per event) as a scannable QR (`QrImage`). "Show this to staff for
check-in and to peers to connect." 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 - **Points breakdown** — sums `points_log` by category
(Session check-ins / Connections / Feedback / Other) + Total. (Session check-ins / Connections / Feedback / Other) + Total.
- **Log out** — `signOut()`. - **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 root [`roadmap.md`](../roadmap.md); this file is the working detail for the
current phase. current phase.
> **Current state:** Phases 0–8 are complete and verified, plus a round of > **Current state:** Phases 0–8 are complete and verified, plus two polish
> **Fixes & Refinements** (QR token moved to the registration, role-pill > rounds: **Fixes & Refinements** (QR token moved to the registration, role-pill
> capitalization, connection detail sheet + red-dot recalc, admin schedule > 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 > Remaining work is cross-cutting (real event clock, deployment, testing) and
> the open questions in [backend/interfaces.md](./backend/interfaces.md). > 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); - **"My picks today"** — shows only **2 rows** (current + next slot's pick);
"tap to change" is a **hyperlink** to the Agenda. "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 ## Cross-cutting / later
- **Real event clock** — replace the simulated `DEFAULT_NOW` - **Real event clock** — replace the simulated `DEFAULT_NOW`
@@ -0,0 +1,53 @@
-- =============================================================================
-- Convivo — Admin password + attendee profile self-service
--
-- 1. `contacts.password` — an admin-only property: the admin's APPE Admin login
-- password. It is independent of the per-event QR token, so an admin can log
-- into APPE Admin at any time, regardless of the active event.
--
-- NOTE: Supabase Auth has a single password per user
-- (`auth.users.encrypted_password`). For `contacts.password` to work as the
-- APPE Admin login, the matching `auth.users.encrypted_password` must be its
-- bcrypt hash. Admins set both directly in Supabase (no self-service UI in
-- v1). The seed gives the dedicated admin a demo password in both places.
--
-- 2. `update_my_profile` — lets a signed-in attendee update their OWN contact
-- row: LinkedIn URL + the two visibility toggles (show_email / show_linkedin).
-- Scoped to the caller (`current_email()`); only those three columns are
-- writable, so it can't touch `is_admin`, `password`, etc.
-- =============================================================================
-- -----------------------------------------------------------------------------
-- 1. ADMIN PASSWORD (admin-only property on the contact)
-- -----------------------------------------------------------------------------
alter table public.contacts add column if not exists password text;
comment on column public.contacts.password is
'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.';
-- -----------------------------------------------------------------------------
-- 2. UPDATE MY PROFILE (attendee self-service: LinkedIn + visibility)
-- -----------------------------------------------------------------------------
create or replace function public.update_my_profile(
p_linkedin_url text, p_show_email boolean, p_show_linkedin boolean
)
returns public.contacts
language plpgsql security definer set search_path = public as $$
declare
v_email text := public.current_email();
v_contact public.contacts;
begin
if v_email is null then raise exception 'not authenticated'; end if;
update public.contacts
set linkedin_url = case when p_linkedin_url is null or btrim(p_linkedin_url) = ''
then null else btrim(p_linkedin_url) end,
show_email = coalesce(p_show_email, false),
show_linkedin = coalesce(p_show_linkedin, false)
where email = v_email
returning * into v_contact;
if not found then raise exception 'contact not found'; end if;
return v_contact;
end;
$$;
grant execute on function public.update_my_profile(text, boolean, boolean) to authenticated;
+19 -16
View File
@@ -28,7 +28,7 @@ insert into auth.users (instance_id, id, aud, role, email, encrypted_password, e
('00000000-0000-0000-0000-000000000000', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-DIE-4458', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Diego Ferreira"}', now(), now(), now(), now()), ('00000000-0000-0000-0000-000000000000', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-DIE-4458', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Diego Ferreira"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-MNA-2210', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Marina Costa"}', now(), now(), now(), now()), ('00000000-0000-0000-0000-000000000000', 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-MNA-2210', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Marina Costa"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'cccccccc-cccc-cccc-cccc-cccccccccccc', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-LUC-9987', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Lucas Oliveira"}', now(), now(), now(), now()), ('00000000-0000-0000-0000-000000000000', 'cccccccc-cccc-cccc-cccc-cccccccccccc', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-LUC-9987', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"Lucas Oliveira"}', now(), now(), now(), now()),
('00000000-0000-0000-0000-000000000000', 'dddddddd-dddd-dddd-dddd-dddddddddddd', 'authenticated', 'authenticated', '[email protected]', crypt('CVV-ADM-0001', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"APPE Admin"}', now(), now(), now(), now()) ('00000000-0000-0000-0000-000000000000', 'dddddddd-dddd-dddd-dddd-dddddddddddd', 'authenticated', 'authenticated', '[email protected]', crypt('appe-admin-2026', gen_salt('bf')), now(), '', '', '', '', '{"provider":"email","providers":["email"]}', '{"full_name":"APPE Admin"}', now(), now(), now(), now())
on conflict (id) do nothing; on conflict (id) do nothing;
insert into auth.identities (id, provider_id, identity_data, provider, user_id, created_at, updated_at, last_sign_in_at) values insert into auth.identities (id, provider_id, identity_data, provider, user_id, created_at, updated_at, last_sign_in_at) values
@@ -53,21 +53,24 @@ on conflict (id) do nothing;
-- Dr. Elena Vasquez is an external keynote speaker (no registration / auth user). -- Dr. Elena Vasquez is an external keynote speaker (no registration / auth user).
-- NOTE: the QR token lives on the REGISTRATION (per event), not the contact. -- NOTE: the QR token lives on the REGISTRATION (per event), not the contact.
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------
insert into public.contacts (email, full_name, linkedin_url, show_email, show_linkedin, is_admin) values -- `password` is the admin-only APPE Admin login password (event-independent).
('[email protected]', 'Ana Silva', 'https://linkedin.com/in/anasilva', true, true, false), -- Only the dedicated admin is seeded with one (demo value; override in Supabase).
('[email protected]', 'Bruno Costa', 'https://linkedin.com/in/brunocosta', false, true, true), -- Staff (Bruno/Rita) keep their QR token as the auth password for the attendee app.
('[email protected]', 'Rita Lopes', null, false, false, true), insert into public.contacts (email, full_name, linkedin_url, show_email, show_linkedin, is_admin, password) values
('[email protected]','Tomás Ribeiro', null, false, false, false), ('[email protected]', 'Ana Silva', 'https://linkedin.com/in/anasilva', true, true, false, null),
('sofia.almeida@loop.com', 'Sofia Almeida', null, false, false, false), ('bruno.costa@acme.com', 'Bruno Costa', 'https://linkedin.com/in/brunocosta', false, true, true, null),
('marco.chen@deepmind.com', 'Marco Chen', null, false, false, false), ('rita.lopes@globant.com', 'Rita Lopes', null, false, false, true, null),
('[email protected]', 'Julia Santos', null, false, false, false), ('[email protected]','Tomás Ribeiro', null, false, false, false, null),
('pedro.nunes@microsoft.com', 'Pedro Nunes', null, false, false, false), ('sofia.almeida@loop.com', 'Sofia Almeida', null, false, false, false, null),
('carla.mendes@quintoessencial.com', 'Carla Mendes', null, false, false, false), ('marco.chen@deepmind.com', 'Marco Chen', null, false, false, false, null),
('diego.ferreira@stone.com', 'Diego Ferreira', null, false, false, false), ('julia.santos@ifood.com', 'Julia Santos', null, false, false, false, null),
('[email protected]', 'Marina Costa', null, false, false, false), ('[email protected]', 'Pedro Nunes', null, false, false, false, null),
('[email protected]', 'Lucas Oliveira', null, false, false, false), ('[email protected]', 'Carla Mendes', null, false, false, false, null),
('[email protected]', 'APPE Admin', null, false, false, true), ('[email protected]', 'Diego Ferreira', null, false, false, false, null),
('[email protected]', 'Dr. Elena Vasquez', null, false, false, false) ('[email protected]', 'Marina Costa', null, false, false, false, null),
('[email protected]', 'Lucas Oliveira', null, false, false, false, null),
('[email protected]', 'APPE Admin', null, false, false, true, 'appe-admin-2026'),
('[email protected]', 'Dr. Elena Vasquez', null, false, false, false, null)
on conflict (email) do nothing; on conflict (email) do nothing;
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------