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

@@ -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', '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', '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;
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).
-- 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
('[email protected]', 'Ana Silva', 'https://linkedin.com/in/anasilva', true, true, false),
('[email protected]', 'Bruno Costa', 'https://linkedin.com/in/brunocosta', false, true, true),
('[email protected]', 'Rita Lopes', null, false, false, true),
('[email protected]','Tomás Ribeiro', null, false, false, false),
('sofia.almeida@loop.com', 'Sofia Almeida', null, false, false, false),
('marco.chen@deepmind.com', 'Marco Chen', null, false, false, false),
('[email protected]', 'Julia Santos', null, false, false, false),
('pedro.nunes@microsoft.com', 'Pedro Nunes', null, false, false, false),
('carla.mendes@quintoessencial.com', 'Carla Mendes', null, false, false, false),
('diego.ferreira@stone.com', 'Diego Ferreira', null, false, false, false),
('[email protected]', 'Marina Costa', null, false, false, false),
('[email protected]', 'Lucas Oliveira', null, false, false, false),
('[email protected]', 'APPE Admin', null, false, false, true),
('[email protected]', 'Dr. Elena Vasquez', null, false, false, false)
-- `password` is the admin-only APPE Admin login password (event-independent).
-- Only the dedicated admin is seeded with one (demo value; override in Supabase).
-- Staff (Bruno/Rita) keep their QR token as the auth password for the attendee app.
insert into public.contacts (email, full_name, linkedin_url, show_email, show_linkedin, is_admin, password) values
('[email protected]', 'Ana Silva', 'https://linkedin.com/in/anasilva', true, true, false, null),
('bruno.costa@acme.com', 'Bruno Costa', 'https://linkedin.com/in/brunocosta', false, true, true, null),
('rita.lopes@globant.com', 'Rita Lopes', null, false, false, true, null),
('[email protected]','Tomás Ribeiro', null, false, false, false, null),
('sofia.almeida@loop.com', 'Sofia Almeida', null, false, false, false, null),
('marco.chen@deepmind.com', 'Marco Chen', null, false, false, false, null),
('julia.santos@ifood.com', 'Julia Santos', null, false, false, false, null),
('[email protected]', 'Pedro Nunes', null, false, false, false, null),
('[email protected]', 'Carla Mendes', null, false, false, false, null),
('[email protected]', 'Diego Ferreira', null, false, false, false, null),
('[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;
-- -----------------------------------------------------------------------------