pediatric-ai-scribe-v3/migrations
Daniel 22683f3584
Some checks failed
Forgejo Android APK / Root app tests (push) Successful in 46s
Forgejo Docker Build / Root app tests (push) Successful in 56s
Forgejo Android APK / Build signed APK (push) Successful in 2m6s
Forgejo Docker Build / Build Docker image (push) Successful in 15s
Forgejo Docker Build / Deploy to the host (push) Failing after 0s
feat: sign in with a code emailed to you, offered beside the password
The sign-in screen asks for an email first, then offers both ways in together:
a six-digit code sent to that address, or the password. Beside rather than
instead — a code depends on mail being delivered and a password does not, so
neither may be the only route. "Use a different email" goes back a step, and
creating an account stays where it was.

What keeps it from being a second, weaker front door:

- Only a bcrypt hash is stored, so a code read out of the database is not a
  working credential.
- Ten minutes, single use, marked used before the session is issued so a replay
  cannot race it, and requesting a new one deletes the old.
- Five wrong guesses burn it. Six digits is a million possibilities, which is
  plenty against a person and nothing against a script with unlimited tries.
- Requesting a code answers identically whether or not the address exists, and
  every verify failure returns one message. A sign-in screen that says "no such
  account" is a way of finding out who has one.
- Two-factor still applies: a code proves you can read the mailbox, which is one
  factor, and an account that asked for a second still wants it.
- Its own rate limits, tighter for requesting than for attempting, because
  requesting sends mail to someone else's address. These had to be separate
  limiters: Express matches app.use paths on segment boundaries, so
  /api/auth/login does not cover /api/auth/login-code — checked against a real
  router rather than assumed.

Two bugs found while building it, both mine:

authFetch keeps an allowlist of endpoints callable with no verified owner and
rejects everything else before it is sent. The new endpoints were not on it, so
the request never left the browser and surfaced as "Connection error".

reveal() hid elements by appending 'hidden' to className and showed them with a
non-global replace, so hiding twice left two copies and showing stripped one.
The "use a different email" link never reappeared. It uses classList now, which
is idempotent.

Verified against the running server: correct code signs in, the same code again
is refused, a superseded code is refused, five wrong guesses burn it, an expired
one is refused, and the stored value is a hash. In the browser: requesting a
code advances the screen, a wrong code is refused without losing the screen, and
the password route still signs in.

Not yet demonstrated: a correct code typed into the browser. The harness keeps
racing the one-live-code rule — the page's own request supersedes whatever code
the test holds, and with SMTP off the delivered one cannot be read. The same
request reaches the server on the wrong-code path, and the endpoint itself is
verified, but that last step is untested end to end.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dv6sqaY6Vq3ChZHMem3cnU
2026-09-11 20:12:03 +02:00
..
1744600000000_example-no-op.js
1744650000000_add-encounter-version.js
1777003849000_add-personal-notes.js
1777090000000_notes-trash.js improve learning hub generation flow 2026-05-08 09:32:58 +02:00
1777507197626_add-mermaid-diagrams.js
1777600000000_add-clinical-assistant-chats.js
1777700000000_add-prompt-revisions.js feat: ship reviewed prompt history, conversation limits and account protections 2026-09-07 04:01:01 +02:00
1777800000000_generated-images.js feat: integrate durable image jobs/private assets into current core 2026-09-07 16:53:42 +02:00
1777900000000_image-context.js feat: integrate durable image jobs/private assets into current core 2026-09-07 16:53:42 +02:00
1780000000000_drop-model-classification.js fix: separate Scribe/Clinical/Learning prompt sections; drop model classification entirely with scrub migration 2026-09-07 18:22:51 +02:00
1780100000000_registration-invites.js feat: invite-only registration 2026-09-10 23:12:07 +02:00
1780200000000_citation-audit.js feat: citation quality tracking, and the SSO settings fit a phone 2026-09-10 23:44:43 +02:00
1780300000000_user-resources.js feat: My Resources — anyone can generate teaching material, privately 2026-09-11 14:50:54 +02:00
1780400000000_my-resources-images.js feat: PubMed search for My Resources, and an image tool that actually fires 2026-09-11 16:47:08 +02:00
1780500000000_resource-images.js feat: decks are built with python-pptx instead of pandoc, and carry their figures 2026-09-11 19:34:26 +02:00
1780600000000_resource-deck.js feat: the model designs the deck instead of writing markdown for a parser to guess at 2026-09-11 19:49:55 +02:00
1780700000000_login-codes.js feat: sign in with a code emailed to you, offered beside the password 2026-09-11 20:12:03 +02:00