mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Fixed #20705 -- Allowed using PasswordResetForm with user models with an email field not named 'email'.
This commit is contained in:
parent
f7e91cac68
commit
617e36dc1e
8 changed files with 86 additions and 7 deletions
|
@ -26,6 +26,7 @@ from django.utils.translation import ugettext as _
|
|||
from .models.custom_user import (
|
||||
CustomUser, CustomUserWithoutIsActiveField, ExtensionUser,
|
||||
)
|
||||
from .models.with_custom_email_field import CustomEmailField
|
||||
from .models.with_integer_username import IntegerUsernameUser
|
||||
from .settings import AUTH_TEMPLATES
|
||||
|
||||
|
@ -812,6 +813,17 @@ class PasswordResetFormTest(TestDataMixin, TestCase):
|
|||
message.get_payload(1).get_payload()
|
||||
))
|
||||
|
||||
@override_settings(AUTH_USER_MODEL='auth_tests.CustomEmailField')
|
||||
def test_custom_email_field(self):
|
||||
email = 'test@mail.com'
|
||||
CustomEmailField.objects.create_user('test name', 'test password', email)
|
||||
form = PasswordResetForm({'email': email})
|
||||
self.assertTrue(form.is_valid())
|
||||
form.save()
|
||||
self.assertEqual(form.cleaned_data['email'], email)
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
self.assertEqual(mail.outbox[0].to, [email])
|
||||
|
||||
|
||||
class ReadOnlyPasswordHashTest(SimpleTestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue