Ticket #5605: 5605_new.diff
File 5605_new.diff, 2.9 KB (added by , 17 years ago) |
---|
-
django/contrib/auth/models.py
108 108 def create_user(self, username, email, password=None): 109 109 "Creates and saves a User with the given username, e-mail and password." 110 110 now = datetime.datetime.now() 111 user = self.model(None, username, '', '', email.strip().lower(), 'placeholder', False, True, False, now, now) 111 emailusername, emaildomain = email.strip().split('@', 1) 112 user = self.model(None, username, '', '', emailusername + '@' + emaildomain.lower(), 'placeholder', False, True, False, now, now) 112 113 if password: 113 114 user.set_password(password) 114 115 else: … … 226 227 for backend in auth.get_backends(): 227 228 if hasattr(backend, "get_all_permissions"): 228 229 permissions.update(backend.get_all_permissions(self)) 229 return permissions 230 return permissions 230 231 231 232 def has_perm(self, perm): 232 233 """ … … 238 239 # Inactive users have no permissions. 239 240 if not self.is_active: 240 241 return False 241 242 242 243 # Superusers have all permissions. 243 244 if self.is_superuser: 244 245 return True 245 246 246 247 # Otherwise we need to check the backends. 247 248 for backend in auth.get_backends(): 248 249 if hasattr(backend, "has_perm"): -
docs/authentication.txt
168 168 The ``User`` model has a custom manager that has the following helper functions: 169 169 170 170 * ``create_user(username, email, password=None)`` -- Creates, saves and 171 returns a ``User``. The ``username``, ``email`` and ``password`` are set 172 as given, and the ``User`` gets ``is_active=True``. 171 returns a ``User``. The ``username`` and ``password`` are set as 172 given, the domain portion of ``email`` gets lowercased, and the 173 ``User`` gets ``is_active=True``. 173 174 174 175 If no password is provided, ``set_unusable_password()`` will be called. 175 176 -
tests/regressiontests/auth_backends/tests.py
69 69 True 70 70 >>> user.has_perms(['auth.test3', 'auth.test_group']) 71 71 True 72 73 # bug #5605, preserve the case of the user name (before the @ in the email address) 74 # when creating a user. 75 76 >>> user = User.objects.create_user('testusercase2', 'tesT@EXAMple.com', 'test') 77 >>> user.email 78 'tesT@example.com' 79 >>> user = User.objects.create_user('testusercase3', u'tesT@EXAMple.com', 'test') 80 >>> user.email 81 u'tesT@example.com' 72 82 """}