Fixed security issue with password update.

This commit is contained in:
Antoine Nguyen
2023-04-14 18:44:23 +02:00
parent 288f62a75a
commit 130257c96a
2 changed files with 12 additions and 0 deletions
+5
View File
@@ -92,6 +92,11 @@ class ProfileForm(forms.ModelForm):
confirmation, self.instance)
else:
self.add_error("oldpassword", _("This field is required."))
elif newpassword or confirmation:
if not confirmation:
self.add_error("confirmation", _("This field is required."))
else:
self.add_error("newpassword", _("This field is required."))
return self.cleaned_data
def save(self, commit=True):
+7
View File
@@ -146,6 +146,13 @@ class ProfileTestCase(ModoTestCase):
self.client.login(username="user@test.com", password="toto"), True
)
self.ajax_post(
reverse("core:user_profile"),
{"oldpassword": "toto",
"confirmation": "tutu"},
status=400
)
self.ajax_post(
reverse("core:user_profile"),
{"oldpassword": "toto",