Project

General

Profile

Actions

Sub-Task #187

open

Epic #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

Added by Bricklou 8 months ago. Updated 23 days ago.

Status:
Done
Priority:
Normal
Assigned To:
Target version:
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 MessageResponse on 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 UserPasswordChanged sends password_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.

Updated by Bricklou 8 months ago Author Actions #1

  • Status changed from Draft to To Do

Updated by Bricklou 24 days ago Author Actions #2

  • Description updated (diff)

Updated by Bricklou 24 days ago Author Actions #3

  • Status changed from To Do to Planned
  • Assigned To set to Bricklou
  • Target version set to Server 0.1.0
  • Start date deleted (03/28/2026)

Updated by Bricklou 23 days ago Author Actions #4

  • Status changed from Planned to In Progress
  • Start date set to 11/02/2026

Updated by Bricklou 23 days ago Author Actions #5

  • Status changed from In Progress to In Review
  • % Done changed from 0 to 100

Updated by Bricklou 23 days ago Author Actions #6

  • Status changed from In Review to Done
Actions

Also available in: PDF Atom