summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCollin Anderson <cmawebsite@gmail.com>2020-08-19 13:54:30 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-09-03 09:25:21 +0200
commitdaa26acc4e7f134e064c5a6abe4d335f6fa8b249 (patch)
treecbf90c0f43c3f0cd547b231090adfe6bb3664fec
parent6a881197e92a03a8bb7c91440d0a702b6dfd6736 (diff)
Fixed #31978 -- Added username hint to admin's password reset confirmation form.
-rw-r--r--django/contrib/admin/templates/registration/password_reset_confirm.html1
-rw-r--r--tests/auth_tests/test_templates.py6
2 files changed, 7 insertions, 0 deletions
diff --git a/django/contrib/admin/templates/registration/password_reset_confirm.html b/django/contrib/admin/templates/registration/password_reset_confirm.html
index 20ef252b95..7de22336cf 100644
--- a/django/contrib/admin/templates/registration/password_reset_confirm.html
+++ b/django/contrib/admin/templates/registration/password_reset_confirm.html
@@ -19,6 +19,7 @@
<form method="post">{% csrf_token %}
<fieldset class="module aligned">
+ <input style="display: none;" autocomplete="username" value="{{ form.user.username }}">
<div class="form-row field-password1">
{{ form.new_password1.errors }}
<label for="id_new_password1">{% translate 'New password:' %}</label>
diff --git a/tests/auth_tests/test_templates.py b/tests/auth_tests/test_templates.py
index ec1a4e5b75..9651bf585d 100644
--- a/tests/auth_tests/test_templates.py
+++ b/tests/auth_tests/test_templates.py
@@ -52,6 +52,12 @@ class AuthTemplateTests(TestCase):
response = client.get(url)
self.assertContains(response, '<title>Enter new password</title>')
self.assertContains(response, '<h1>Enter new password</h1>')
+ # The username is added to the password reset confirmation form to help
+ # browser's password managers.
+ self.assertContains(
+ response,
+ '<input style="display: none;" autocomplete="username" value="jsmith">',
+ )
def test_PasswordResetCompleteView(self):
response = PasswordResetCompleteView.as_view()(self.request)