Skip to content

D98 · Postgres decides an invitation, one server-only module in apps/web sends it, and its link lasts 24 hours

Proposed · 2026-11-10 · zuki, in the team session on #454 (M1-01); it binds when this page's pull request is merged · Applies to access (ACC), D13, D37, D48, D50, D51 · Partly superseded by D101 (an email whose login has no membership in the organization can be invited)

Decision: An invitation is decided and recorded in Postgres: invite_member() checks user:write and what the inviter may grant at the pool, refuses with a stable key, and writes the invitation. One server-only module in apps/web holds the secret key and calls Supabase Auth's admin invite for that invitation only; it holds no rule. The invite link lasts 24 hours. An invitation carries one role at one pool. An email that already has a login is refused. A pending invitation can be resent, which sends a fresh link and moves its expiry. When the invitee opens the link, the database rechecks that the inviter could still grant the role; if so it makes the membership and the role, and accepting ends no sessions.

Why: Only Auth's admin invite makes an invited login and sends its email, and it needs the secret key. Keeping every check in Postgres holds D3; sending from the app server lets a failed send reach the inviter at once. A database-side send through pg_net and Vault would hide a failed send and reload the key on every reset, and an Edge Function adds a runtime that is off today for no gain. zuki chose these options in the session, as recommended.

Consequences:

  • The secret key appears in apps/web in one server-only module, for Auth's admin invite and resend only. apps/web's guard that refuses the key (lib/supabase/env.ts) and its working note allow that module and nothing else; the publishable key stays the only key every other part of apps/web uses (D13). The key is set by hand in each hosted environment (L0), never in the repository.
  • Accepting an invitation ends no sessions, like the super_admin grant at a new pool (D48, R-ACC-55): the login had no access before, so nothing it holds is stale, and stamping it would sign the invitee out as their first session starts. D37 and D48 hold for every other change.
  • The invite link's expiry is Auth's otp_expiry, 86400 seconds, locally and on each hosted project, so a password-reset link lasts 24 hours too (D51).
  • A suspended member is restored, not re-invited, and an existing login in another organization isn't joined here; both wait for M1-04 or a real case.
  • Revoking a pending invitation, and several roles in one invitation, are left to M1-04 and M1-02.
  • The invite email is Indonesian only: the invitee has no locale yet, and Auth's template has one language.