Authentication
Sign in with Apple and Google, the email link for development, roles, deleting an account.
Accounts are Supabase Auth's. The apps sign in with supabase-js; the database sees the user in
every request (auth.uid()), and PowerSync accepts the same token. There is no auth server of our
own.
Methods
Listoca signs in with Apple and Google only (D3 in docs/plans/lists/01-decisions.md): no passwords,
no sign-up form, no second factor. The first sign-in makes the account; the provider's name fills
the profile's when it is empty.
| Method | Native | Web (the admin area) |
|---|---|---|
| Apple | the system sheet, signInWithIdToken (iOS) | no button yet |
the system sheet, signInWithIdToken | no button yet | |
| Email link | development builds only (or the email-sign-in flag) | the seeded demo admins |
The email link exists for simulators, where Apple and Google are awkward: the auth email carries
a link into the app (listoca://auth/callback, app/auth/callback.tsx) next to the 6-digit code,
and lands in Mailpit. Production Auth has the email provider off, so even a hand-made request is
refused. Apple and Google accounts of one person are two accounts; Settings says which one is
signed in.
Configuration
What the apps offer is packages/auth/src/config.ts; what Supabase Auth allows is
supabase/config.toml locally ([auth.external.apple], [auth.external.google], redirect URLs,
hooks) and the Auth container's environment in production
(deploy/supabase/overrides.env.example). Keep both in step.
Roles and permissions
A platform role lives in user_roles and reaches the token as app_role (the custom access
token hook). UIs ask checkPermission(session, "admin.access")
(packages/auth/src/permissions.ts); the database checks private.is_admin() itself. Never
compare role strings in feature code.
Account deletion
delete-account (an Edge Function) deletes the user after a recent sign-in; their lists, tasks,
steps, marks and memberships go with them through foreign keys, and lists they owned disappear
for the people they shared them with. The app offers to keep a copy on the device. A store
subscription keeps running until it's cancelled in the store, which the app says before
deleting. The marketing site's /legal/delete-account is the page the stores ask for.
Errors
Supabase's error codes map to translated messages (authErrors.<code> in the shared scope,
packages/auth/src/client.ts).