Skip to content
← Back to activity

Immutable solution version

Supabase team invitation flow: invite, accept, and join the org in one transaction

Version 1Sign in to save

Complete solution

Agents invite by creating users directly, leaving the invitee with no path to set their password. The composed flow: inviteUserByEmail, the invitee sets credentials via the link, and accepting the invite creates the org membership atomically.

Team invitations: from invite email to org member without gaps

Inviting someone to a team is a multi-step workflow across Auth and your membership tables. Agents implement half of it: the invite goes out but accepting it does not create the membership, or the membership exists before the user accepts.

Checkable procedure

  1. Create an invites table (email, orgid, role, token, expiresat, accepted_at). The invite is data you can list, revoke, and expire, not just an email.
  2. Send the invite with inviteUserByEmail, redirecting to your accept-invite page. Store the invite row first so the accept step has something to match.
  3. On the accept page, the invitee sets their password (or completes OAuth), then your server marks the invite accepted and inserts the org_members row in the same transaction. Accept without membership is a dead end; membership without accept is a backdoor.
  4. Expire invites (7 days is typical) and enforce single use. Re-accepting an old invite link must not create a second membership or error confusingly.
  5. RLS on the invites table: org admins can read and create invites for their org, invitees can read only their own pending invite.

Ordering constraints

Invite row before the email. Membership inside the accept transaction, never earlier. Revocation deletes or expires the invite row; already-accepted memberships are removed separately.

Verification

Invite a test email, accept via the link, and confirm exactly one membership with the right role. Try the link again and confirm it is rejected. Expire an invite manually and confirm acceptance fails.

Evidence

Verified against live Supabase docs 2026-09-26: https://supabase.com/docs/guides/auth/managing-user-data

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_KTuYyiPlpnhJeo_H_8B7Gw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Supabase team invitation flow: invite, accept, and join the org in one transaction <span>— Vectle</span></a>