feat(auth): onInvitationAccepted host seam — afterAcceptInvitation forwarded to the host (ADR-0105 D8 prerequisite) - #3645
Merged
Conversation
…rwarded to the host (ADR-0105 D8 prerequisite) An invitation may carry placement intent (target BU + positions, extension fields on sys_invitation per the ADR-0092 whitelist), but there was no server-side seam to apply it at accept time — better-auth's org-plugin models don't fire core databaseHooks (#3541 D8 note: 'there is no afterAcceptInvitation hook today'). AuthManagerConfig.onInvitationAccepted mirrors onOrganizationCreated: invoked from organizationHooks.afterAcceptInvitation with mapped ids (invitationId, organizationId, userId, memberId, role, email) plus the RAW invitation/member rows so a host reads its own extension columns without a second query. Failure-isolated — acceptance never rolls back on a side-effect miss; hosts needing effectively-atomic placement make the callback idempotent and reconcile on retry. Tests: payload mapping + raw-row pass-through, failure isolation, no-op without the callback. plugin-auth 508/508; guards clean; changeset (minor). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015FebXPaaGrLhGKw1LHPbpL
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 9 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
os-zhuang
marked this pull request as ready for review
July 27, 2026 12:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unblocks ADR-0105 D8 (scoped invitations) — #3541's Phase 2 note called this out: "there is no
afterAcceptInvitationhook today — atomic placement needs one".What
AuthManagerConfig.onInvitationAccepted, mirroring the existingonOrganizationCreatedseam (same rationale: better-auth's org-plugin models don't fire coredatabaseHooks, soorganizationHooksis the only server-side seam for accept-time side effects):organizationHooks.afterAcceptInvitation(native in the pinned better-auth 1.7) with the mapped ids —invitationId,organizationId,userId,memberId,role,email— plus the rawinvitation/memberrows, so a host reads its own extension columns (the D8 placement intent: target business unit + positions, carried onsys_invitationper the ADR-0092 whitelist) without a second query.Cloud's D8 scoped-invitation UX (objectstack-ai/cloud#874 checklist) builds on this: issue the invitation with placement intent under the existing
adminScopeanti-escalation gate, apply placement in this callback.Verification
@objectstack/plugin-auth: 508/508 tests green.🤖 Generated with Claude Code
https://claude.ai/code/session_015FebXPaaGrLhGKw1LHPbpL
Generated by Claude Code