feat: add magic-link admin login and speaker materials portal
This commit is contained in:
1 parent
3adc0fd58f
commit
8d8d3ae4b8
28 files changed
+1623
-232
No files matched your search
+37
-4
@@ -130,18 +130,51 @@ The `materials` bucket (public read) stores session material. Policies on
|
||||
create policy "materials_read" on storage.objects for select to authenticated
|
||||
using (bucket_id = 'materials');
|
||||
create policy "materials_write" on storage.objects for insert to authenticated
|
||||
with check (bucket_id = 'materials' and public.is_speaker_or_admin());
|
||||
with check (bucket_id = 'materials' and public.can_write_session_material(name));
|
||||
create policy "materials_update" on storage.objects for update to authenticated
|
||||
using (bucket_id = 'materials' and public.is_speaker_or_admin());
|
||||
using (bucket_id = 'materials' and public.can_write_session_material(name))
|
||||
with check (bucket_id = 'materials' and public.can_write_session_material(name));
|
||||
create policy "materials_delete" on storage.objects for delete to authenticated
|
||||
using (bucket_id = 'materials' and public.is_speaker_or_admin());
|
||||
using (bucket_id = 'materials' and public.can_write_session_material(name));
|
||||
```
|
||||
|
||||
Speakers + admins can write; any authenticated attendee can read (download).
|
||||
Registered speakers can write only their own non-service session paths; admins
|
||||
retain material management access. Any authenticated attendee can read (download).
|
||||
Because the `sessions` table is admin-write only, a speaker attaches their
|
||||
uploaded file via the `set_session_material` RPC (see
|
||||
[rpcs.md](./rpcs.md#set_session_materialp_session_id-p_material_path--sessions)).
|
||||
|
||||
## Speaker Portal Authorization
|
||||
|
||||
Source: [speaker portal migration](../../supabase/migrations/20261006175631_speaker_portal.sql),
|
||||
with [staff overlap](../../supabase/migrations/20261007153957_speaker_portal_staff_overlap.sql).
|
||||
`owns_speaker_session(session_id)` requires the JWT's `current_email()` to have
|
||||
both a `session_speakers` assignment and a `registrations.type` of `speaker` or `staff`
|
||||
for that session's event. The slot must belong to the same event and be type
|
||||
`session`, not `service_session`. Assignment alone, registration alone,
|
||||
attendee/sponsor assignments, or another speaker's registration is insufficient.
|
||||
Admin/organizer staff can also speak without changing category or losing staff
|
||||
points/check-in exclusions. There is no separate `organizer` enum value.
|
||||
Automatic staff links to service slots do not grant portal ownership.
|
||||
Admins retain global material management access, but the portal lists only their own talks.
|
||||
|
||||
Neither event activation, event date nor `checked_in` enters this predicate.
|
||||
`can_write_session_material(path)` accepts speaker paths only in the form
|
||||
`sessions/<UUID>/<non-empty filename>` and checks the referenced session's
|
||||
ownership. UPDATE checks both old and new names, preventing reassignment to
|
||||
foreign paths. Public material reads are intentionally unchanged.
|
||||
|
||||
The portal read and material setter are security-definer functions with an empty
|
||||
search path and qualified object names. EXECUTE is revoked from PUBLIC/anon and
|
||||
granted to authenticated/service_role; role membership alone does not grant
|
||||
speaker access. The setter checks ownership again, locks the session row and
|
||||
verifies a non-null object exists in `materials` under the exact session path.
|
||||
It cannot update registrations, points logs, check-ins or leaderboard rows.
|
||||
|
||||
See [RPCs](./rpcs.md#speaker-portal-rpcs), [transactional tests](./tests.md#speaker-portal)
|
||||
and [frontend entry points](../frontend/screens.md#speaker-portal). The normal
|
||||
app's physical check-in gate remains separate and unchanged.
|
||||
|
||||
## GRANTs
|
||||
|
||||
The new Supabase CLI does **not** auto-expose new tables to the Data API roles, so
|
||||
|
||||
Reference in new issue
Block a user