Ticket #25232: 25232.diff

File 25232.diff, 2.4 KB (added by Tim Graham, 9 years ago)
  • django/contrib/auth/backends.py

    diff --git a/django/contrib/auth/backends.py b/django/contrib/auth/backends.py
    index 9f08259..3f3d1fa 100644
    a b class ModelBackend(object):  
    1515            username = kwargs.get(UserModel.USERNAME_FIELD)
    1616        try:
    1717            user = UserModel._default_manager.get_by_natural_key(username)
    18             if user.check_password(password):
     18            if user.check_password(password) and user.is_active:
    1919                return user
    2020        except UserModel.DoesNotExist:
    2121            # Run the default password hasher once to reduce the timing
    class ModelBackend(object):  
    9090    def get_user(self, user_id):
    9191        UserModel = get_user_model()
    9292        try:
    93             return UserModel._default_manager.get(pk=user_id)
     93            user = UserModel._default_manager.get(pk=user_id)
    9494        except UserModel.DoesNotExist:
    9595            return None
     96        return user if user.is_active else None
    9697
    9798
    9899class RemoteUserBackend(ModelBackend):
  • django/test/client.py

    diff --git a/django/test/client.py b/django/test/client.py
    index 945fa13..a44970a 100644
    a b class Client(RequestFactory):  
    594594        """
    595595        from django.contrib.auth import authenticate
    596596        user = authenticate(**credentials)
    597         if (user and user.is_active and
    598                 apps.is_installed('django.contrib.sessions')):
     597        if user and apps.is_installed('django.contrib.sessions'):
    599598            self._login(user)
    600599            return True
    601600        else:
  • tests/test_client/tests.py

    diff --git a/tests/i18n/commands/locale/en/LC_MESSAGES/django.mo b/tests/i18n/commands/locale/en/LC_MESSAGES/django.mo
    old mode 100644
    new mode 100755
    diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py
    index ae70f5c..c016735 100644
    a b class ClientTest(TestCase):  
    461461        self.assertRedirects(response, '/accounts/login/?next=/login_protected_view/')
    462462
    463463        # Log in
    464         self.client.force_login(self.u2)
    465 
    466         # Request a page that requires a login
    467         response = self.client.get('/login_protected_view/')
    468         self.assertEqual(response.status_code, 200)
    469         self.assertEqual(response.context['user'].username, 'inactive')
     464        self.assertFalse(self.client.force_login(self.u2))
    470465
    471466    def test_logout(self):
    472467        "Request a logout after logging in"
Back to Top