Ticket #5605: 5605_new.patch

File 5605_new.patch, 2.5 KB (added by Leo, 5 years ago)

revised patch against r12623

  • django/contrib/auth/models.py

     
    105105    def create_user(self, username, email, password=None):
    106106        "Creates and saves a User with the given username, e-mail and password."
    107107        now = datetime.datetime.now()
    108         user = self.model(None, username, '', '', email.strip().lower(), 'placeholder', False, True, False, now, now)
     108        # Make only the domain lowercase.
     109        parts = email.strip().split('@', 1)
     110        if len(parts) > 1:
     111            parts[1] = parts[1].lower()
     112        email = '@'.join(parts)
     113        user = self.model(None, username, '', '', email, 'placeholder', False, True, False, now, now)
    109114        if password:
    110115            user.set_password(password)
    111116        else:
  • django/contrib/auth/tests/forms.py

     
    219219>>> form.cleaned_data['email']
    220220u'jsmith3@example.com'
    221221
     222# bug #5605, preserve the case of the user name (before the @ in the email address)
     223# when creating a user.
     224>>> user = User.objects.create_user('test2', 'tesT@EXAMple.com', 'test')
     225>>> user.email
     226'tesT@example.com'
     227>>> user = User.objects.create_user('test3', 'tesT', 'test')
     228>>> user.email
     229'tesT'
     230
    222231"""
  • docs/topics/auth.txt

     
    291291
    292292        Creates, saves and returns a :class:`~django.contrib.auth.models.User`.
    293293        The :attr:`~django.contrib.auth.models.User.username`,
    294         :attr:`~django.contrib.auth.models.User.email` and
    295         :attr:`~django.contrib.auth.models.User.password` are set as given, and the
    296         :class:`~django.contrib.auth.models.User` gets ``is_active=True``.
    297 
     294        :attr:`~django.contrib.auth.models.User.password` are set as given,
     295        the domain portion of :attr:`~django.contrib.auth.models.User.email`
     296        gets lowercased, and the :class:`~django.contrib.auth.models.User` gets
     297        ``is_active=True``.
     298       
    298299        If no password is provided,
    299300        :meth:`~django.contrib.auth.models.User.set_unusable_password()` will
    300301        be called.
Back to Top