fix: Map reset-token verification failures to their dedicated variants #75
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
rosa/vernier!75
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/reset-token-error-mapping"
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?
Fixes #54.
reset_passwordwrappedConfirmation::verify_nouserfailures in an anyhow context, funnellingConfirmationError::Expiredand verifier mismatches intoResetPasswordError::Unknown, which the web layer renders as a 500. A user clicking a reset link after the 30-minute window got a generic 500 page instead of a link-expired message.Changes
From<ConfirmationError> for ResetPasswordErrorconversion:Expiredmaps toConfirmationExpired,VerifierMismatchtoConfirmationVerifierMismatch, not-found/ID-mismatch cases toConfirmationNotFound,InvalidActiontoInvalidTokenAction, andUnknownstaysUnknown.reset_passwordnow propagatesverify_nouserfailures through that conversion instead of.with_context(...), so expired/forged tokens render the existing invalid-confirmation (4xx) response. Genuine faults (repository errors, hashing) still surface asUnknown/500.From<ResetPasswordError> for AppErrorarms already mapped the dedicated variants toAppError::InvalidConfirmation.get_confirmation_by_token(form-rendering path) for consistency: it already returnsConfirmationErrordirectly, which the web layer maps to the invalid-confirmation response, so no change was needed there.Tests
ConfirmationErrorvariant reachable fromverify_nouser(Expired,VerifierMismatch,IdMismatch), plusUnknownstayingUnknown.ConfirmationExpired; presenting the right confirmation ID with the wrong verifier yieldsConfirmationVerifierMismatch.b67dec44f96a0f30d178