diff options
| author | Claude Paroz <claude@2xlibre.net> | 2013-10-19 10:40:20 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2013-10-19 10:43:06 +0200 |
| commit | 5f52590368063fc8284e23be492d83ba751f66bf (patch) | |
| tree | a557a45e0fbab6262ccff2edabd95cf1beacd1c7 /django | |
| parent | 59a8808632dc64b13b4b576ef9ce2a26ab897943 (diff) | |
Fixed #21291 -- Ensured inactive users cannot reset their passwords
Thanks kz26 for the report and the suggested fix. Refs #19758.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/auth/forms.py | 5 | ||||
| -rw-r--r-- | django/contrib/auth/tests/test_forms.py | 1 |
2 files changed, 4 insertions, 2 deletions
diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py index ec70da2910..b13131fc94 100644 --- a/django/contrib/auth/forms.py +++ b/django/contrib/auth/forms.py @@ -238,8 +238,9 @@ class PasswordResetForm(forms.Form): from django.core.mail import send_mail UserModel = get_user_model() email = self.cleaned_data["email"] - users = UserModel._default_manager.filter(email__iexact=email) - for user in users: + active_users = UserModel._default_manager.filter( + email__iexact=email, is_active=True) + for user in active_users: # Make sure that no email is sent to a user that actually has # a password marked as unusable if not user.has_usable_password(): diff --git a/django/contrib/auth/tests/test_forms.py b/django/contrib/auth/tests/test_forms.py index de58641226..bf9a002770 100644 --- a/django/contrib/auth/tests/test_forms.py +++ b/django/contrib/auth/tests/test_forms.py @@ -436,6 +436,7 @@ class PasswordResetFormTest(TestCase): user.save() form = PasswordResetForm({'email': email}) self.assertTrue(form.is_valid()) + form.save() self.assertEqual(len(mail.outbox), 0) def test_unusable_password(self): |
