From aaabce9873f18cd64ef1aec36b061d0eb36c51fd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 20:58:17 +1000 Subject: [PATCH] Fix set password when no old password exists (#5562) (#5563) (cherry picked from commit fe68598c1b4aa8ba5c4710a195054048baff7306) Co-authored-by: Firas Ben Mefteh --- InvenTree/InvenTree/forms.py | 1 + InvenTree/InvenTree/views.py | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/InvenTree/InvenTree/forms.py b/InvenTree/InvenTree/forms.py index 9206676ab7..6d55d8f583 100644 --- a/InvenTree/InvenTree/forms.py +++ b/InvenTree/InvenTree/forms.py @@ -161,6 +161,7 @@ class SetPasswordForm(HelperForm): old_password = forms.CharField( label=_("Old password"), strip=False, + required=False, widget=forms.PasswordInput(attrs={'autocomplete': 'current-password', 'autofocus': True}), ) diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py index 101659eb75..1fc121eb17 100644 --- a/InvenTree/InvenTree/views.py +++ b/InvenTree/InvenTree/views.py @@ -447,8 +447,7 @@ class SetPasswordView(AjaxUpdateView): if valid: # Old password must be correct - - if not user.check_password(old_password): + if user.has_usable_password() and not user.check_password(old_password): form.add_error('old_password', _('Wrong password provided')) valid = False