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:
expiresAtis in the past, orusedAtordeclinedAtis set
Lifecycle Operations
| Operation | Action | Audit Event |
|---|---|---|
| Accept | Sets usedAt | INVITATION_USED |
| Decline | Sets declinedAt | INVITATION_DECLINED |
| Cancel | Soft-deletes invitation | INVITATION_CANCELED |
| Permanent delete | Removes record | INVITATION_PERMANENTLY_DELETED |
Auditing
All write paths audit dataBefore and dataAfter snapshots with:
tenantIdperformedBy- Optional
userIp