Skip to content

Commit

Permalink
Fixed security issue with password update.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonioo committed Apr 14, 2023
1 parent 288f62a commit 130257c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modoboa/core/forms.py
Expand Up @@ -92,6 +92,11 @@ def clean(self):
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):
Expand Down
7 changes: 7 additions & 0 deletions modoboa/core/tests/test_core.py
Expand Up @@ -146,6 +146,13 @@ def test_update_password(self):
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",
Expand Down

0 comments on commit 130257c

Please sign in to comment.