From 50dfe7f5b09213ee6755454eeff6c7fc80320122 Mon Sep 17 00:00:00 2001 From: keylor2906 Date: Wed, 18 Sep 2024 04:15:10 -0600 Subject: [PATCH] [FIX] password_security: Fix reset password when user doesn't have password_write_date value. It happens that when you install the module, all the users that previously existed before that won't have a value set for the new field password_write_date. And when the validation of minimal hours has passed between the last password write date and now is done, it gets an error of unsupported operands between a bool and timedelta. With this change, it won't be necessary to validate the last password date if it's the first time reseting password, and when the password is changed it will correctly save the value on password_write_date and will be working normally afterwards. --- password_security/models/res_users.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/password_security/models/res_users.py b/password_security/models/res_users.py index 8a5213e4b6..cc78c1a9d9 100644 --- a/password_security/models/res_users.py +++ b/password_security/models/res_users.py @@ -144,6 +144,8 @@ def _validate_pass_reset(self): if pass_min <= 0: continue write_date = user.password_write_date + if not write_date: + continue delta = timedelta(hours=pass_min) if write_date + delta > datetime.now(): raise UserError(