Fix set password when no old password exists ()

This commit is contained in:
Firas Ben Mefteh 2023-09-18 18:51:17 +08:00 committed by GitHub
parent a68c1d28c6
commit fe68598c1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions
InvenTree/InvenTree

View File

@ -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}),
)

View File

@ -443,8 +443,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