Repository navigation
fix(auth): claim the account when an unverified phone is proven - #15058
Conversation
Proving an unverified phone by OTP sign-in or a signed-out team invite must revoke whatever the registrant kept, as an unverified email does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A phone OTP sign-in or a signed-out phone invite now revokes the registrant's credentials, mirroring the email claim. The claim keeps the proven phone and drops the email, as the email claim drops the phone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. No issues found — approved ✅. This PR makes account-claim revocation channel-aware:
Reviewed commit: 9860d11 |
🟢 Tier S · Ready to mergeThis change claims accounts when an unverified phone is proven during phone-token exchange or signed-out phone-invite acceptance. Credential revocation now preserves the proven channel and removes the other address, with end-to-end coverage for both flows.
📂 Walkthrough · 5
🔇 Filtered out · 1Findings Hansi considered but did not post.
Reviewed |
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
What does this PR do?
Proving an unverified email already claims the account:
User::revokeCredentialsdrops whatever the registrant kept (password, sessions, tokens, MFA, passkeys, identities, account keys, the phone and non-email targets). Proving an unverified phone did nothing of the kind, so an account registered with someone else's phone kept the registrant's password and sessions after the phone's owner signed in.This mirrors the claim for phone at every site where a signed-out caller proves a phone:
$createSession:PUT /v1/account/sessions/phone,POST /v1/account/sessions/token): a phone OTP on an account whosephoneVerificationis false now runs the claim, under the same user row lock and transaction as the email branch.revokeCredentialstakes the proven channel (MESSAGE_TYPE_EMAILby default, orMESSAGE_TYPE_SMS). It keeps the proven address and its targets, and drops the other address: an email claim drops the phone (unchanged), a phone claim drops the email and its metadata.Semantics
The email claim fires whenever the proven email is unverified, regardless of a verified phone, and drops that phone. The phone claim is the exact mirror: it fires whenever the proven phone is unverified, regardless of a verified email, and drops that email. Leaving the email in place would keep a way back in for whoever registered the account (password recovery or email OTP to their own address), so the claim would not hold. Sites that are not claims stay as they are: verifying a phone while signed in, and accepting an invite while signed in, change nothing.
Test Plan
AccountCustomClientTest::testCreatePhoneSessionRevokesUnverifiedAccountCredentials: a registrant with a password and a verified email adds a phone they do not own; the phone's owner signs in by OTP. Asserts the registrant's session and password are rejected and the email is gone, while the owner's session works withphoneVerificationtrue.TeamsCustomClientTest::testUpdateMembershipStatusByPhoneRevokesUnverifiedAccountCredentials: an anonymous account adds a phone it does not own; the phone's owner accepts an invite signed out. Asserts the registrant's session is rejected.Related PRs and Issues
Tracking: appwrite-labs/cloud#7065
🤖 Generated with Claude Code