Commits

Gautier Hayoun committed 2a87bd6

Fix regression introduced in previous commit

  • Participants
  • Parent commits d4eba58

Comments (0)

Files changed (2)

File django_webtest/middleware.py

         # getting passed in the headers, then the correct user is already
         # persisted in the session and we don't need to continue.
         if request.user.is_authenticated():
-            if request.user.get_username() == self.clean_username(username, request):
+            if hasattr(request.user, "get_username"):
+                authenticated_username = request.user.get_username()
+            else:
+                authenticated_username = request.user.username
+            if authenticated_username == self.clean_username(username, request):
                 return
         # We are seeing this user for the first time in this session, attempt
         # to authenticate the user.

File django_webtest_tests/testapp_tests/tests.py

             assert user.is_authenticated()
             self.assertEqual(user, custom_user)
 
+    def test_normal_user(self):
+        """Make sure the fix for custom users in django 1.5 doesn't break
+        normal django users"""
+        self.app.get('/template/index.html', user=self.user)
+        self.app.get('/template/index.html', user=self.user)
+
 
 class EnvironTest(BaseAuthTest):