1.8 KiB
1.8 KiB
Invite Link Limits Implementation Plan
Checklist
- Update Trellis planning artifacts and get approval to start implementation.
- Load pre-development specs with
trellis-before-dev. - Update
modules/core/server/schema.ts:- Add
maxUsesandusedCountinteger columns toorganizationInvitations.
- Add
- Generate or add the Drizzle migration for the new columns.
- Update shared invitation types and row mappers:
modules/core/types.tsmodules/core/server/settings.tsmodules/core/server/store.ts
- Update invitation creation API:
- Parse
validityDaysandmaxUses. - Validate positive integer ranges.
- Persist
expiresAt,maxUses, andusedCount.
- Parse
- Update invitation registration flow:
- Reject exhausted links.
- Increment usage inside the transaction.
- Mark status accepted only when
usedCountreachesmaxUses. - Guard concurrent consumption with an update predicate.
- Update frontend:
- Add validity and maximum-use controls to
OrganizationInviteDialog. - Display usage count in
OrganizationDetailClient. - Update invitation explanatory text where it still says invitations are one-time only.
- Add validity and maximum-use controls to
- Run validation:
pnpm lintpnpm type-checkpnpm testif tests are relevant or fast enough after type changes.pnpm buildif lint/type-check pass.
Risk Points
- Concurrent registrations could over-consume an invite unless the update predicate checks
used_count < max_uses. - Existing accepted invitations should remain unusable regardless of migrated counter defaults.
- Frontend numeric inputs submit strings, so backend parsing must not trust the client.
Rollback Points
- Before migration: schema/API/UI changes can be reverted together.
- After migration: reverting code while keeping columns is safe because defaults preserve one-use invite behavior.