Actions
Sub-Task #187
openEpic #3: Implement a secure user authentication system
Feature #162: Password Recovery
User Story #186: As a user, I want to reset my password, so that I can regain access
Validate reset token and update password securely
Sub-Task #187:
Validate reset token and update password securely
Start date:
11/02/2026
Due date:
% Done:
100%
Estimated time:
Description
Server side of the password reset (#186).
Endpoint
POST /api/v1/authentication/reset-password, body{ token, password, confirm_password }.- 200
MessageResponseon success. 410 for an invalid token (see #185). 422 when the password breaks the security policy or the confirmation differs. 429 on the shared limiter.
Service reset(db, bus, token, password, now)
- Validates the password with the existing security policy and the confirmation, then hashes it with the existing
PasswordHasher. - In one transaction: consume the token, update the password hash, delete all sessions of the user (
delete_by_user(txn, id, None)), write an audit row. - After commit: publish
UserPasswordChanged. - Modeled on
user/service/password.rs(change_password). - MFA is not bypassed: the next sign-in still asks the second factor.
Password changed mail
- New handler on
UserPasswordChangedsendspassword_changed.mjml(username, time, "if this was not you" text). Registered next to the other user mail handlers.
Tests
- Success: password changed, sessions gone, audit row written, event published, old password refused, new one accepted.
- Policy and confirmation errors keep the token usable.
- Token refused after use.
- Mail handler sends one mail on
UserPasswordChanged.
Actions