Skip to content

fix(otp): sign in by phone only with a verified phone - #513

Merged
Bccorb merged 1 commit into
mainfrom
fix/require-verified-phone-for-sign-in
Oct 29, 2026
Merged

Bccorb merged 1 commit into
mainfrom
fix/require-verified-phone-for-sign-in

Conversation

@Bccorb

@Bccorb Bccorb commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

What

A phone number now has to be verified before it can be used to sign in, and an account that is already verified can no longer have a phone verified through the pre-auth registration routes.

  • POST /login looks an account up by phone only when that phone is verified, and lists phone_otp only for a verified phone.
  • /otp/generate-login-phone-otp answers an unverified phone as it answers an account with no phone (400 Invalid data). /otp/verify-login-phone-otp refuses it (401 Not allowed).
  • /otp/generate-phone-otp and /otp/verify-phone-otp (registration, pre-auth token) no longer act on an already verified account: sending answers 200 and sends nothing, verifying answers 401. Adding or verifying a phone on a verified account goes through /registration/phone, which takes an access session.
  • The policy dry run treats an unverified phone as no phone, matching sign-in.

Each new answer is one a decoy or an account with no phone already gives, so none of them distinguishes real accounts.

Compatibility

Phone-first sign up (verify the phone, then the email, on one attempt) is unchanged and covered by a test. A client that verified the email first and then the phone on the same pre-auth token no longer gets the phone verified; it should add the phone with the session it receives. The SDK flows do not do this. Only deployments with phone_otp in login_methods are affected; it is off by default.

Tests

  • New tests/postgres/unverifiedPhoneClaim.spec.ts runs the real app and migration chain over HTTP: three cases for unverified phones, plus a phone-first sign up control.
  • Unit tests for each guard, and fixtures updated where they modeled a registration phone step on an already verified account.

Checks

  • npm run typecheck, npm run lint, npm run format:check: pass
  • npm run test:run: 157 files, 2357 passed
  • npm run coverage: 98.91 / 95.32 / 99.24 / 99.11
  • Postgres project (TEST_DB=postgres): 7 files, 37 passed
  • npm run generate:api: no diff
  • Changeset: patch

/login finds an account by phone, and offers phone_otp, only when the phone is
verified, and the login phone OTP routes refuse an unverified one. The
registration phone OTP routes no longer verify a phone on an account that is
already verified; that takes an access session through /registration/phone.
@Bccorb
Bccorb merged commit 736e0ee into main Oct 29, 2026
9 checks passed
@Bccorb
Bccorb deleted the fix/require-verified-phone-for-sign-in branch October 29, 2026 02:15
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