Skip to content

Treat every ORCID conflict as orcid_in_use - #308

Merged
neuromechanist merged 1 commit into
stagingfrom
feature/issue-305-orcid-in-use
Sep 6, 2026
Merged

Treat every ORCID conflict as orcid_in_use#308
neuromechanist merged 1 commit into
stagingfrom
feature/issue-305-orcid-in-use

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #305.

nemar-cli #1254 (ADR 0043) makes an ORCID iD back at most one live NEMAR account and returns a typed code on every refusal. orcid_in_use and the deprecated orcid_already_linked alias mean the same thing to a user (which D1 constraint noticed is not something anyone can act on), but the website only ever switched on orcid_already_linked, and nothing mapped orcid_in_use at all — so the new race-path refusals from nemar-cli #1254 would have fallen through to a generic "something went wrong" message.

  • Added src/lib/identity-errors.ts: one shared IDENTITY_CONFLICT_MESSAGES map keyed on orcid_in_use (with orcid_already_linked folded in as an alias to the exact same sentence), plus email_in_use and github_in_use, each mirroring the wording of the backend's shared/contract/identity.ts IDENTITY_CONFLICT_MESSAGES. orcid_linked_other is kept as its own distinct message (it's the settings link/relink refusal — a different account already holds the finished iD — not a sign-up conflict).
  • Wired the shared mapping into the three surfaces that can render one of these codes:
    • src/pages/auth/orcid/complete.astro (sign-up finalize) — previously had no orcid_in_use entry at all, and its own divergent email_in_use / orcid_already_linked copy.
    • src/pages/login.astro — previously had neither orcid_in_use nor orcid_already_linked.
    • src/pages/settings.astro — previously had neither orcid_in_use nor orcid_already_linked.
  • Confirmed by grep that orcid_already_linked no longer appears as a branch/case anywhere in src/ or test/ — it exists only as the alias key (plus explanatory comments) inside identity-errors.ts.

Testing

  • bun run test — 1916 tests pass, including new src/lib/identity-errors.test.ts (alias resolves to the identical string as orcid_in_use; orcid_linked_other stays distinct; unknown codes degrade to undefined; Object.hasOwn-based lookup is prototype-safe against constructor/__proto__/etc.) and new test/identity-conflict-pages.test.ts (source-level guards, following test/signin-notice.test.ts's pattern, that all three pages import and spread the shared mapping and that none of them hardcode a competing orcid_already_linked / orcid_linked_other / email_in_use string).
  • bun run typecheck — 0 errors (pre-existing unrelated hints only).
  • bunx biome check --write on all changed files — clean.
  • NEMAR_SKIP_OG_GENERATE=1 bun run build — succeeds.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying nemar-website with  Cloudflare Pages  Cloudflare Pages

Latest commit: a3bdeed
Status: ✅  Deploy successful!
Preview URL: https://327eef89.nemar-website.pages.dev
Branch Preview URL: https://feature-issue-305-orcid-in-u.nemar-website.pages.dev

View logs

Add a shared identity-errors mapping so orcid_in_use and the deprecated
orcid_already_linked alias render one sentence, and email_in_use /
github_in_use / orcid_linked_other get consistent copy too. Wired into
the ORCID finalize (complete.astro), login, and settings pages, which
previously either lacked orcid_in_use entirely or hardcoded their own
divergent wording.

complete.astro's browser script reads its lookup key straight from a
fetch() JSON response, so it now calls the exported
identityConflictMessage() helper (Object.hasOwn-guarded internally)
instead of indexing the shared map directly, which would have resolved
a prototype key ("constructor", "toString") to a function rather than
undefined.
@neuromechanist
neuromechanist force-pushed the feature/issue-305-orcid-in-use branch from a3bdeed to 00fa38e Compare September 6, 2026 03:08
@neuromechanist
neuromechanist merged commit 4f2298e into staging Sep 6, 2026
4 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-305-orcid-in-use branch September 6, 2026 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant