Commit c9c2d92
fix(plugin-auth): adopt the existing membership when accepting an invitation instead of colliding on the unique index (#7796)
* fix(plugin-auth): adopt the existing membership when accepting an invitation
better-auth's accept-invitation route inserts a sys_member row
unconditionally. The platform auto-binds every user to the default org at
sign-up (ADR-0093 D1/D2), so on a single-org deployment that insert collides
with the reconciler's row on sys_member's declared unique
{organization_id, user_id} index. The route's transaction catch rolls the
invitation back to `pending` and rethrows, which surfaced as a bodyless HTTP
500 and an invitation that could never be accepted (#7725).
Adopt that row instead of minting a second one, at the better-auth -> ObjectQL
adapter: the declared unique pair IS the identity of a membership, so a create
naming an existing pair is that membership. Adoption writes the invitation's
role onto the adopted row, but never lowers a grade -- demotion belongs to
update-member-role, where last-admin-guard stands.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BVc1ekPpi6yaWywAUhfzfd
* test(plugin-auth): pin invitation acceptance adoption in both directions (#7725)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BVc1ekPpi6yaWywAUhfzfd
* chore(changeset): patch @objectstack/plugin-auth for #7725
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BVc1ekPpi6yaWywAUhfzfd
* test(plugin-auth): pin the adoption fake's update() to ObjectQL's dispatch predicate
check:engine-double-contract flagged the new engine double: it pinned delete
but not update, and update is the verb the adoption write actually uses.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BVc1ekPpi6yaWywAUhfzfd
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 1a19e9d commit c9c2d92
6 files changed
Lines changed: 931 additions & 1 deletion
File tree
- .changeset
- packages/plugins/plugin-auth/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
0 commit comments