feat(2fa): preserve QR + manual key when verification code is wrong #99
No reviewers
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
psa-systems/bunyip!99
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/bunyip-upgrade-04-2fa-preserve"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The 2FA setup POST handler replaced the entire enrollment view with just
"Invalid verification code · Try again" when the user typed the wrong code. The QR image, the manual key, and the input field all disappeared, so a one-digit typo or a 30-second clock-drift turned into "scan a brand new QR from scratch." Auditor finding 6.
Refactor:
twofa_setup_view(setup, error). The optionalerrorargument renders a red banner above the code input. Both the GET handler (no error) and the POST error path (banner-with-message) call this helper, so the QR + manual key on a retry render are byte-identical to the entry render.Errbranch re-fetches the in-progress secret viaauth_api::setup_2faand feeds it totwofa_setup_viewwithSome(err_msg). This relies on the bunyip-api/v1/auth/2fa/setupendpoint returning the SAME pending secret while an enrollment is in flight - if the upstream mints a fresh secret per call, the user has to rescan after every wrong code (same UX bug, different mechanism). The API-side note indocs/bunyip-upgrade/04-2fa-error-state-preserves-form.mdflags that prerequisite.autocomplete="one-time-code"so iOS / Chrome can surface a freshly-arrived TOTP from a sibling tab.Imports:
TwoFactorSetupResponseis added to thecrate::api::typesuse block so the new view helper can name the type without crate-rooting.Closes audit finding 6. See
docs/bunyip-upgrade/04-2fa-error-state-preserves-form.mdfor the full spec and verification.