Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.2.X] Fixed #8342 -- Removed code from the admin that assumed that …

…you can't login with an email address (nixed by r12634).

Backport from trunk (r14769).

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14773 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit a607d9d34546a4ff9313d431e275ed0bf365d42a 1 parent 1155b49
Jannis Leidel authored December 02, 2010
4  django/contrib/admin/sites.py
@@ -327,13 +327,11 @@ def login(self, request):
327 327
                 try:
328 328
                     user = User.objects.get(email=username)
329 329
                 except (User.DoesNotExist, User.MultipleObjectsReturned):
330  
-                    message = _("Usernames cannot contain the '@' character.")
  330
+                    pass
331 331
                 else:
332 332
                     if user.check_password(password):
333 333
                         message = _("Your e-mail address is not your username."
334 334
                                     " Try '%s' instead.") % user.username
335  
-                    else:
336  
-                        message = _("Usernames cannot contain the '@' character.")
337 335
             return self.display_login_form(request, message)
338 336
 
339 337
         # The user data is correct; log in the user in and continue.
4  django/contrib/admin/views/decorators.py
@@ -60,10 +60,6 @@ def _checklogin(request, *args, **kwargs):
60 60
                 users = list(User.objects.filter(email=username))
61 61
                 if len(users) == 1 and users[0].check_password(password):
62 62
                     message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username
63  
-                else:
64  
-                    # Either we cannot find the user, or if more than 1
65  
-                    # we cannot guess which user is the correct one.
66  
-                    message = _("Usernames cannot contain the '@' character.")
67 63
             return _display_login_form(request, message)
68 64
 
69 65
         # The user data is correct; log in the user in and continue.
8  tests/regressiontests/admin_views/tests.py
@@ -453,12 +453,12 @@ def testLogin(self):
453 453
         self.assertContains(login, "Your e-mail address is not your username")
454 454
         # only correct passwords get a username hint
455 455
         login = self.client.post('/test_admin/admin/', self.super_email_bad_login)
456  
-        self.assertContains(login, "Usernames cannot contain the '@' character")
  456
+        self.assertContains(login, "Please enter a correct username and password")
457 457
         new_user = User(username='jondoe', password='secret', email='super@example.com')
458 458
         new_user.save()
459 459
         # check to ensure if there are multiple e-mail addresses a user doesn't get a 500
460 460
         login = self.client.post('/test_admin/admin/', self.super_email_login)
461  
-        self.assertContains(login, "Usernames cannot contain the '@' character")
  461
+        self.assertContains(login, "Please enter a correct username and password")
462 462
 
463 463
         # Add User
464 464
         request = self.client.get('/test_admin/admin/')
@@ -962,12 +962,12 @@ def test_staff_member_required_decorator_works_as_per_admin_login(self):
962 962
         self.assertContains(login, "Your e-mail address is not your username")
963 963
         # only correct passwords get a username hint
964 964
         login = self.client.post('/test_admin/admin/secure-view/', self.super_email_bad_login)
965  
-        self.assertContains(login, "Usernames cannot contain the '@' character")
  965
+        self.assertContains(login, "Please enter a correct username and password")
966 966
         new_user = User(username='jondoe', password='secret', email='super@example.com')
967 967
         new_user.save()
968 968
         # check to ensure if there are multiple e-mail addresses a user doesn't get a 500
969 969
         login = self.client.post('/test_admin/admin/secure-view/', self.super_email_login)
970  
-        self.assertContains(login, "Usernames cannot contain the '@' character")
  970
+        self.assertContains(login, "Please enter a correct username and password")
971 971
 
972 972
         # Add User
973 973
         request = self.client.get('/test_admin/admin/secure-view/')

0 notes on commit a607d9d

Please sign in to comment.
Something went wrong with that request. Please try again.