Skip to content

[19.0][FIX] password_security: keep password_write_date when the new password is rejected - #1072

Open
alvaro-domatix wants to merge 1 commit into
OCA:19.0from
alvaro-domatix:19.0-fix-password_security-rejected-password-expiration
Open

alvaro-domatix wants to merge 1 commit into
OCA:19.0from
alvaro-domatix:19.0-fix-password_security-rejected-password-expiration

Conversation

@alvaro-domatix

Copy link
Copy Markdown

When a user with an expired password is sent to the reset page and types one of their previous passwords, the history check rejects it, but password_write_date has already been set in the same write() call. web_auth_reset_password (and the portal security page) catch the UserError and the request is committed, so the expiration date is refreshed although the password did not change. On the next login the old password is accepted again for another full period.

Steps to reproduce:

  1. Set an expiration (e.g. 90 days) and a password history (e.g. 10).
  2. Make a user's password expire and log in: Odoo redirects to /web/reset_password.
  3. Submit the current password: "Cannot use the most recent 10 passwords" is displayed.
  4. Log in again with the same password: the user gets in, and password_write_date is now today.

This change writes password_write_date only once super().write() has succeeded. The new test fails without the change, and the whole password_security suite passes with it.

As far as we can tell the same happens in 17.0 and 18.0, and we can open the backports if this approach looks right to you. We may be missing a reason to write the date in the same call, so please let us know if there is a preferred way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:password_security Module password_security series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants