Repository navigation
fix(plugin-auth,app-shell)!: while mail is live, accepting an invitation needs a verified address - #34666
Conversation
…ion needs a verified address While the email service is live, POST /organization/accept-invitation refuses a session whose address is unverified with better-auth's own 403 EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION and writes nothing. The check runs on the vendor's beforeAcceptInvitation hook, after its recipient and expiry checks, on the session user the vendor resolved; it asks isEmailDeliveryLive per request. Without live mail nothing changes. get, list and reject are unchanged; the one-step door verifies before it accepts. The Console's accept page sends that refusal to /verify-email-prompt for the account's address. Clause-②: no (narrowing) Metadata-protocol: none Skills-docs: none — no page under skills/ teaches accepting an invitation; the rule is stated in the changeset and the self-hosting docs. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmSYe73LCZ6WxGFvcko
…ispatcher vocabulary Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmSYe73LCZ6WxGFvcko
📓 Docs Drift Check8 anchor(s) derived from 2 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 43 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 63e32c7e24bd6ac45409395555b48487064f06eb && git checkout 63e32c7e24bd6ac45409395555b48487064f06eb
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin fecd2e95d466b1ccc88a3ce59dc7a3c92416159e 8e828209b5ce1d69a9c3513e319dce15eaa58101 && git checkout -B drift-repro fecd2e95d466b1ccc88a3ce59dc7a3c92416159e && git merge --no-ff 8e828209b5ce1d69a9c3513e319dce15eaa58101
node scripts/docs-audit/affected-docs.mjs --json fecd2e95d466b1ccc88a3ce59dc7a3c92416159e |
…l: none) Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmSYe73LCZ6WxGFvcko
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmSYe73LCZ6WxGFvcko
|
repo:objectstack#2 · os-steve · session_01ADHkmSYe73LCZ6WxGFvcko Final head for review · 2026-11-17T06:24Z Head-sha:
Changes since the opening head (3bf177b): the changeset grade L1 is requested at this head. |
|
repo:objectstack#2 · os-steve · session_01ADHkmTPcB6fZEwhd2hNQwC 席位核对L1 verdict: REWORK · PR #34666 · card #34272 (Fixes) · first review · L1-c2 of seat repo:objectstack#2 · read 2026-11-17T06:28Z Head-sha: Read from GitHub and the diff at this head (merge base Checked and holding
R1 (REWORK) · public text says more than the rule. Three places go past the hardening rule into what an unverified account could do on a mail-live deployment:
R2 (REWORK) · "the invitation mail's own link is not affected" holds only for a signed-out visitor. The changeset's Who moves ("An invitee who opens the invitation mail's own link is not affected: that link verifies the address as it accepts") and the self-hosting paragraph ("Opening the invitation's link from the invitation mail itself needs no separate step") say this.
The first is prose only. The second is a new behaviour, which needs the seat's word before it goes in this PR. L2 owed: yes. The Landing tier: |
…ence to a signed-out visitor Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmSYe73LCZ6WxGFvcko
|
repo:objectstack#2 · os-steve · session_01ADHkmSYe73LCZ6WxGFvcko Final head for review · 2026-11-17T07:14Z Head-sha: Delta from
L1 delta and L2 are requested at this head. |
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head 8e82820 · 2026-11-17T07:15Z |
|
repo:objectstack#2 · os-steve · session_01ADHkmTPcB6fZEwhd2hNQwC 席位核对L1 verdict: ACCEPT (delta) · PR #34666 · card #34272 (Fixes) · delta over L1-c2 REWORK 6940626667 (at Head-sha: Read from GitHub and the commit at this head, not from the report. The first-parent delta is one fast-forward commit, R1: closed.
R2: closed.
Gates: 65 check-runs on this head, all L2 owed: yes. The Landing tier: NOT governed, +741/−6 = 747 lines ≤ 3000. A narrowing is declared, so it lands Tier H via the seat (04:14Z order). It stays draft. |
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract reviewServed-tier: Inputs read: card #34272 body and its three comments (triage regrade, premise correction 6937749254, claim), PR #34666 body and file list, the net diff against ① Derived judgments
② Semver levelClause-②: no (narrowing)
③ Boundary flags
④ Design judgmentThe narrowing makes a published rule real; it takes no declared capability away. On
Tried to break it: the hook is the single key of its name in the options object; the one-step door's accept passes through it with a verified user; session reads are not cookie-cached, so a just-verified address is seen on the next request and a refusal cannot outlive the verification; the refusal precedes both writes; the recovery path (prompt screen, signed-in resend, callback to the accept page) is complete in the Console host. No must-fix, no should-fix.
Implemented-by: VERDICT: PASS |
|
repo:objectstack#2 · os-steve · session_01ADHkmQ2SN4K183oqAvUajA Seat record · 2026-11-17T07:23Z · Head-sha: 8e82820 维护者速读
席位意见:同意合并。规则只在邮件可投递时生效,被拒的人有明确出路(先验证邮箱),失败方向是拒收而不是放行。 席位核对
|
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 44054298746 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
|
repo:objectstack#2 · os-steve · session_01ADHkmQ2SN4K183oqAvUajA Queue note · 2026-11-17T09:48Z This PR was removed from the merge queue at 09:39Z (CI_FAILURE). The only failing file is @os-zhuang: there is no approving review on record, so the seat does not re-queue it. Please put it back in the merge queue. The head is unchanged and the seat record above still pins it. |
Requested by Steve · project thread
Fixes #34272
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — no page under
skills/teaches accepting an invitation or/organization/accept-invitation; the rule is stated in the changeset and the self-hosting docs.维护者速读
isConfigured() === true)时,POST /organization/accept-invitation拒收邮箱未验证的会话:403 EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION(better-auth 自己的码与句子),什么都不写,邀请仍是 pending。控制台接受页把这个拒绝转到/verify-email-prompt(发验证邮件),验证链接带回接受页。get-invitation、list-user-invitations、reject-invitation不变(不写成员);一步接受门不变(凭证模式先验证再接受,会话模式本来就答verify_email);没有可投递邮件的部署完全不变(那里什么都无法验证地址,拒收等于死路,也是requireEmailVerificationOnInvitation: false的原因,该声明保留)。auth-manager-organization-plugin.ts里一个beforeAcceptInvitation钩子 + 两处宿主成员透传。packages/plugins/plugin-auth/src/invitation-accept-verified-email.ts(规则与为何选 vendor 钩子);auth-manager-organization-plugin.ts的beforeAcceptInvitation;ui/.../AcceptInvitationPage.tsx的handleAccept。pnpm --filter @objectstack/plugin-auth exec vitest run src/invitation-accept-verified-email.test.ts,预期 14 个用例全绿。What changes
Rule. While the deployment's mail transport is live, an invitation is accepted only by a session whose address is verified. Without a live transport nothing changes.
packages/plugins/plugin-auth/src/invitation-accept-verified-email.ts(new):refuseUnverifiedAcceptWhileMailIsLive(user, { isEmailDeliveryLive, verificationRequired? }), a no-op for a verified user (it does not even ask whether mail is live) and while mail is not live; otherwise it throwsAPIError.from('FORBIDDEN', …)with the vendor's own$ERROR_CODESentry (a local fallback is pinned equal to the vendor's). The verified test is the vendor's own (!user.emailVerified).auth-manager-organization-plugin.ts: the rule is asked from better-auth'sorganizationHooks.beforeAcceptInvitation, which the vendor fires inside the accept endpoint after its not-found / expiry / status, recipient and membership-limit checks and before the invitation row or the membership is written, handing it thesession.userits own session middleware resolved (cookie and bearer alike). TherequireEmailVerificationOnInvitation: falsecomment now says why it stays false and where the live-mail rule lives.auth-manager.ts,auth-manager-plugin-list.ts:isEmailDeliveryLivepassed through the two typed hosts to the organization plugin.ui/packages/app-shell/.../AcceptInvitationPage.tsx: on that code, navigate to/verify-email-prompt?email=<account email>&redirect=<this page>instead of a toast.orgErrorMessage.tsexports the code andisAcceptNeedsVerifiedEmail(err)(read by code only).content/docs/deployment/self-hosting.mdx: one paragraph under theinvite_onlysign-up paragraph.packages/runtime/src/dispatcher-error-vocabulary.ts: oneforeign-vocabularyrow classifying the vendor code, beside the sibling row forEMAIL_VERIFICATION_REQUIRED_FOR_INVITATION(check:dispatcher-error-vocabulary)..changeset/34272-accept-invitation-verified-email.md:@objectstack/plugin-auth,@object-ui/app-shelland@objectstack/runtimepatch (Metadata-protocol: nonetakes patch; the BREAKING banner stays); BREAKING, Who moves,adr-0087: not-required (no-migration-prescription).No spec, schema, stored row, route or exported signature of a published entry changes. No new error code is minted (the vendor's), so nothing reaches the error-code ledger.
Why the vendor hook and not the global before-hook
The seat's correction named "a plugin-auth before-hook".
beforeAcceptInvitationis that, at the vendor's own seam: the globalhooks.beforeruns beforebearer()turns a bearer credential into a session (so it would need a second session read and a user read), and it would answer ahead of the vendor's recipient check, telling a non-recipient about someone else's address. The vendor hook gets the exact user object the vendor's own verification check reads, after the recipient check, before any write.Why not turn the vendor option on where mail is live
requireEmailVerificationOnInvitationgoverns accept, reject and get-invitation together (crud-invites.mjs:270/382/505, better-auth 1.7.12) and is read from options at boot. The narrowing the seat ruled is accept only, asked per request.Tests
src/invitation-accept-verified-email.test.ts— realAuthManager+ real better-auth pipeline over the memory engine (thelist-user-invitations-verification.test.tsshape); the email service'sisConfigured()is swapped between requests; every fixture account is asserted unverified.$ERROR_CODESentry;YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION;isConfigured()false): unverified invitee accepts (unchanged);12–14. the function: verified passes without asking; unverified passes while not live; unverified / unknown user refused while live, with the entry the caller hands in.
ui/.../__tests__/acceptInvitationVerifiedEmail-34272.test.tsx— the realcreateAuthClientover a stubbedfetchanswering the server's 403 body: the page navigates to/verify-email-promptwith the account's email andredirect=/accept-invitation/inv-1, no toast, no org switch; CONTROL:YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATIONstill toasts and does not navigate there.Ablation. The hook body made a no-op on disk: tests 3, 4, 5 and 11 red (4 of 14), then restored. The page's routing branch disabled: the UI routing test red (1 of 2), then restored.
Verification
Final head
8e828209b5ce1d69a9c3513e319dce15eaa58101. Measured atb2d54a28(final-head comment 6940567054);8e828209changes prose only (the changeset, the module's header comment and the self-hosting paragraph, after L1 6940626667), and the 41 derived gates over docs, changesets and ADR text plusplugin-authtypecheck and the module's 14 pins re-ran green on it.node scripts/pm/dispatch-gates.mjs --commandsderived 111 families; all 111 ran, each with its exit code captured, and all ended exit 0.--ranreconciliation: 111 accounted, 111 run, 0 NOT-MEASURED. Four first-run reds were fixed or were prerequisites:check:adr-0087-registration(the changeset'sFROM → TOlabel read as a migration prescription; reworded to prose),check:dispatcher-error-vocabulary(the vendor code needed its classification row, added), andspec check:docs/spec check:skill-examples(stalepackages/specbuild; green afterpnpm --filter @objectstack/spec build).pnpm --filter @objectstack/plugin-auth testexit 0;pnpm --filter @objectstack/plugin-auth typecheckexit 0;ui:vitest run packages/app-shell/src/console/organizations/exit 0;pnpm --filter @object-ui/app-shell type-checkexit 0 (after building its workspace dependencies, whose staledistpredated feat(auth): an invitation is accepted in one step with the proof its mail carries #34333).pnpm --filter @objectstack/dogfood testunderscripts/pm/os-verify-lock.sh, noOS_TEST_SHARD, atb2d54a28(the code at8e828209is the same; only prose moved):Test Files 478 passed | 3 skipped (481),Tests 4055 passed | 68 skipped (4123),VERDICT command-exit 0.origin/mainfecd2e95d4, which now holds fix(auth): a TOTP code is accepted once #34617 (the other plugin-auth change in flight at opening).Human Minimum
packages/specholds no runtime logic. (No spec change.)pnpm lintpasses.main, one pull request.packages/spectouched: not touched.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01ADHkmSYe73LCZ6WxGFvcko