Developers/Workflow/User Invitation Flow: Difference between revisions

From wiki.storlye.com
Jump to navigationJump to search
m Protected "Developers/Workflow/User Invitation Flow": Developers area managed by admins ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))
Document invited_user_id purpose
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
== Developers/Workflow/User Invitation Flow ==


This page describes the current invitation flow used by Storlye.
=== Why user_invitations.invited_user_id exists ===
 
* The invitation starts without a target account, so invited_user_id is NULL at creation time.
=== Purpose ===
* After signup starts, backend binds the invitation to the real created account by setting invited_user_id.
Allow a superadmin to invite a new user by email, WhatsApp context, or QR sharing using the same invitation token context in the active modal.
* During signup confirmation, backend uses email plus invited_user_id to attach the pending user connection safely.
 
* This avoids ambiguity when emails are reused/resubmitted and preserves invitation audit traceability.
=== Entry Points ===
* POST /v1/admin/invitations/preview-link
* POST /v1/admin/invitations/send
* POST /auth/signup (with optional inviteToken)
* POST /auth/signup-confirmation/verify
* GET /v1/widgets/pending-people-invites
* PATCH /v1/user-connections/:connectionId/respond-me
 
=== Flow ===
# Superadmin opens invite modal.
# Frontend requests POST /v1/admin/invitations/preview-link.
# Backend creates a pending invitation row in user_invitations with token hash and TTL, then returns invitationId, inviteToken, and inviteLink.
# Frontend renders a QR code from the invite link. The link is already valid before pressing Send.
# If Send Invite is pressed, frontend calls POST /v1/admin/invitations/send reusing invitationId plus inviteToken and optional contact fields (email/whatsapp).
# Backend updates or creates invitation data and returns final inviteLink. If email is provided, email delivery is attempted.
# Invitee signs up using inviteToken in POST /auth/signup.
# Invitation status moves to signup_pending_confirmation and gets associated with invited user id.
# Invitee confirms account with POST /auth/signup-confirmation/verify.
# Backend attaches pending connection based on invitation context.
# Invitee can accept or decline in pending people invites widget via PATCH /v1/user-connections/:connectionId/respond-me.
 
=== Data Notes ===
* user_invitations stores token hash (never plain token), contact channels, status lifecycle, and inviter/invitee references.
* user_connections is updated after signup confirmation and finalized on invite response (confirmed or declined).
 
=== Current Behavior ===
* QR and Send in the same modal reuse the same token context.
* WhatsApp is stored as invitation context; automatic WhatsApp delivery is not integrated yet.
 
=== Maintenance Rule ===
* Update this page in the same change cycle whenever invitation endpoints, statuses, or flow steps change.
 
Last update: 2026-06-15 14:32:05 UTC

Latest revision as of 13:19, 15 June 2026

Why user_invitations.invited_user_id exists

  • The invitation starts without a target account, so invited_user_id is NULL at creation time.
  • After signup starts, backend binds the invitation to the real created account by setting invited_user_id.
  • During signup confirmation, backend uses email plus invited_user_id to attach the pending user connection safely.
  • This avoids ambiguity when emails are reused/resubmitted and preserves invitation audit traceability.