fix(auth): allow recovery codes at 2FA login#19
Merged
Conversation
The TOTP login field filtered input to 6 digits and used a numeric keyboard, so recovery codes (16 hex chars, two hyphenated groups) were untypeable. That locks out exactly the users recovery codes are for: lost or replaced authenticator, which correlates with a changed phone. Add a "Use a recovery code instead" toggle that swaps the field to a hex-friendly keyboard and accepts the code bare or hyphenated, then normalises it (lowercase, hyphen re-inserted) to the stored format on submit. The default stays numeric-keypad TOTP, which is the common case and easier to type. The login endpoint already accepts a recovery code on the same parameter, so this is a client-only change. Also refresh a stale README line that claimed store builds were not yet available, which contradicted the status line right above it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The 2FA login field filtered input to 6 digits (
code.filter { it.isDigit() }.take(6)) with a numeric keyboard, so recovery codes (16 hex chars, issued as two hyphenated groupsxxxxxxxx-xxxxxxxx) were untypeable. That locks out exactly the users recovery codes exist for: a lost or wiped authenticator, which correlates strongly with a changed phone, i.e. mobile-first users. There was no alternate path in the UI.Fix
Add a "Use a recovery code instead" toggle to the login TOTP step:
Client-only change: the login endpoint already tries the authenticator code then falls back to a recovery code on the same
totp_codeparameter, so the server accepted recovery codes all along.One subtlety: recovery codes are stored hashed in their hyphenated form, so the hyphen must be present at submit. Web sends the raw field (the user types the hyphen); on mobile we re-insert it client-side so people can type it bare. That is a deliberate, strictly-more-permissive divergence from web.
Also
Refreshed a stale README line that claimed store builds were "not yet available", contradicting the status line right above it (stable
v*tags are on GitHub Releases; Play Store is in beta; F-Droid pending).Scope note
Other TOTP prompts (member/tag/file/journal delete, orphan-file cleanup, revision pinning, System Safety, data export) are intentionally left digit-only. That matches web, which only offers recovery codes at login (and change-email); those are step-up auth while already signed in, not a lockout.
Testing
:app:testPlayReleaseUnitTestgreen:app:assemblePlayReleasegreen (through R8)