Skip to content

Add OTP toggle and validate encryption_key at startup - #82

Merged
wailbentafat merged 1 commit into
developfrom
fix/otp-toggle-and-encryption-key-validation
Sep 7, 2026
Merged

Add OTP toggle and validate encryption_key at startup#82
wailbentafat merged 1 commit into
developfrom
fix/otp-toggle-and-encryption-key-validation

Conversation

@wailbentafat

Copy link
Copy Markdown
Collaborator

Summary

  • Add OTP_ACTIVATED setting (default false). When off, /user/auth/register creates the user and authenticates immediately (same response shape as /login), skipping the OTP email/verify step entirely.
  • /register response model now accepts RegisterPendingResponse | MobileAuthResponse depending on the flag.
  • Add a field_validator on encryption_key that 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

  • Verified Settings() raises ValidationError and refuses to start when encryption_key is not valid base64 / wrong length
  • Verified the app starts cleanly with a valid 32-byte base64 key
  • Manually registered a mobile user with OTP_ACTIVATED=false and confirmed /register returns tokens directly (200, no pending/OTP step)
  • Manual QA with OTP_ACTIVATED=true to confirm the original OTP flow is unaffected

🤖 Generated with Claude Code

…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>
@wailbentafat
wailbentafat merged commit c569781 into develop Sep 7, 2026
1 of 2 checks passed
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