Add OTP toggle and validate encryption_key at startup - #82
Merged
wailbentafat merged 1 commit intoSep 7, 2026
Conversation
…tartup Add OTP_ACTIVATED setting (default false) so mobile registration can skip the OTP verification step and authenticate immediately, matching pre-OTP-feature behavior. /register now returns MobileAuthResponse directly when the flag is off, or the existing pending/OTP response when it's on. Also add a field_validator on encryption_key that checks it decodes to a valid 128/192/256-bit AES key. An invalid key previously passed startup silently and only surfaced as a 500 on /auth/refresh; now the app refuses to start with a clear error instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
OTP_ACTIVATEDsetting (defaultfalse). When off,/user/auth/registercreates the user and authenticates immediately (same response shape as/login), skipping the OTP email/verify step entirely./registerresponse model now acceptsRegisterPendingResponse | MobileAuthResponsedepending on the flag.field_validatoronencryption_keythat requires it to decode to a valid 128/192/256-bit AES key. Previously an invalid key passed startup silently and only surfaced as a 500 on/auth/refresh(AESGCM key must be 128, 192, or 256 bits); now the app refuses to start with a clear error message.Test plan
Settings()raisesValidationErrorand refuses to start whenencryption_keyis not valid base64 / wrong lengthOTP_ACTIVATED=falseand confirmed/registerreturns tokens directly (200, no pending/OTP step)OTP_ACTIVATED=trueto confirm the original OTP flow is unaffected🤖 Generated with Claude Code