Skip to main content

Invitations Lifecycle

Service: InvitationsService manages create, find by token, expiration checks, accept/decline, cancel and permanent delete.

Create

  • Validates email/tenant/date
  • Generates token
  • Optional audit log INVITATION_CREATED

Lookup by Token

  • Returns Invitation | null
  • 404 from data layer is mapped to null (warn-level log)

Expiration

isExpired(invitation) returns true if:

  • expiresAt is in the past, or
  • usedAt or declinedAt is set

Lifecycle Operations

OperationActionAudit Event
AcceptSets usedAtINVITATION_USED
DeclineSets declinedAtINVITATION_DECLINED
CancelSoft-deletes invitationINVITATION_CANCELED
Permanent deleteRemoves recordINVITATION_PERMANENTLY_DELETED

Auditing

All write paths audit dataBefore and dataAfter snapshots with:

  • tenantId
  • performedBy
  • Optional userIp