Skip to content

🔧 Remove org email-invite (Node) + migration #3812

Description

@PierreBrisorgueil

Phase 4 of the invitations↔org decouple epic. Plan Phase 4. Pairs with Phase 7 (Vue). Ships with its migration.

Remove all org email-invite from Node:

  • organizations.membership.service.js — delete invite (L294-349), acceptInvite (L358-390), getInvite (L398) + exports; drop unused crypto; fix the dedup $in that referenced INVITED (L308).
  • organizations.membershipRequest.controller.js — delete invite/acceptInvite/getInvite (L105-153) + exports.
  • organizations.membershipRequest.routes.js — delete the 3 /invites* routes (L42-57).
  • organizations/lib/constants.js — remove INVITED (L4).
  • organizations.membership.model.mongoose.js — drop 'invited' enum (L30), inviteToken/invitedEmail/inviteExpiresAt (L33-35), sparse index (L51-53).
  • delete config/templates/org-invite.html; fix the stale doc-comment in audit.middleware.js L24; rewrite organizations.lifecycle.e2e.tests.js.
  • Migration modules/organizations/migrations/<ts>-drop-org-invited-memberships.js (org-owned, NOT under the optional invitations module): deleteMany({status:'invited'}), $unset the 3 fields, drop inviteToken_1 index.

Acceptance: /api/invites/* 404; no INVITED/invite refs in modules/organizations; join-requests intact.


🛑 Fable review corrections (2026-06-10, code-verified vs origin/master)

  • Lifecycle e2e invite describe is L58-202 (a single test), NOT L58-145 — rewrite the whole describe. Re-verify ranges on origin/master (local is 115 behind; the org module's membership files are byte-identical HEAD↔origin but organizations.service.js was reworked).
  • Free cleanup: REJECTED:'rejected' in lib/constants.js is dead code (rejectRequest hard-deletes; never written) — drop it.
  • Stale docs to fix on removal: README.md + MIGRATIONS.md document a non-existent /members/invite path and a non-existent MembershipInvite zod schema.
  • Confirmed: removed/left/rejected memberships hard-delete (no lingering doc), so the enum removal won't orphan via those paths; the migration handles the invited rows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions