فهرست منبع

fix validation error on save from autocomplete (#11113)

Chiemezuo 1 سال پیش
والد
کامیت
8f9cb7c007
4فایلهای تغییر یافته به همراه18 افزوده شده و 1 حذف شده
  1. 1 0
      CHANGELOG.txt
  2. 1 0
      docs/releases/5.3.md
  3. 16 0
      wagtail/admin/tests/test_account_management.py
  4. 0 1
      wagtail/admin/views/account.py

+ 1 - 0
CHANGELOG.txt

@@ -5,6 +5,7 @@ Changelog
 ~~~~~~~~~~~~~~~~
 
  * Fix: Update system check for overwriting storage backends to recognise the `STORAGES` setting introduced in Django 4.2 (phijma-leukeleu)
+ * Fix: Prevent password change form from raising a validation error when browser autocomplete fills in the "Old password" field (Chiemezuo Akujobi)
  * Maintenance: Update BeautifulSoup upper bound to 4.12.x (scott-8)
 
 

+ 1 - 0
docs/releases/5.3.md

@@ -19,6 +19,7 @@ depth: 1
 ### Bug fixes
 
  * Update system check for overwriting storage backends to recognise the `STORAGES` setting introduced in Django 4.2 (phijma-leukeleu)
+ * Prevent password change form from raising a validation error when browser autocomplete fills in the "Old password" field (Chiemezuo Akujobi)
 
 ### Documentation
 

+ 16 - 0
wagtail/admin/tests/test_account_management.py

@@ -419,6 +419,22 @@ class TestAccountSection(WagtailTestUtils, TestCase, TestAccountSectionUtilsMixi
         self.user.refresh_from_db()
         self.assertTrue(self.user.check_password("password"))
 
+    def test_ignore_change_password_if_only_old_password_supplied(self):
+        response = self.post_form(
+            {
+                "password-old_password": "password",
+                "password-new_password1": "",
+                "password-new_password2": "",
+            }
+        )
+
+        # Check that everything runs as usual (with a redirect), instead of a validation error
+        self.assertRedirects(response, reverse("wagtailadmin_account"))
+
+        # Check that the password was not changed
+        self.user.refresh_from_db()
+        self.assertTrue(self.user.check_password("password"))
+
     def test_change_notifications(self):
         response = self.post_form(
             {

+ 0 - 1
wagtail/admin/views/account.py

@@ -209,7 +209,6 @@ class ChangePasswordPanel(BaseSettingsPanel):
         if self.request.method == "POST":
             bind_form = any(
                 [
-                    self.request.POST.get(self.name + "-old_password"),
                     self.request.POST.get(self.name + "-new_password1"),
                     self.request.POST.get(self.name + "-new_password2"),
                 ]