From 282d58e19385ee4e5c125a9d3cba820949314f3f Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Mon, 11 Jul 2022 14:27:11 -0400 Subject: [PATCH] Refs #25232 -- Simplified ModelBackend.user_can_authenticate(). Thanks Jay Turner for the suggestion. --- django/contrib/auth/backends.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/django/contrib/auth/backends.py b/django/contrib/auth/backends.py index 1e12efac38..4adcf35051 100644 --- a/django/contrib/auth/backends.py +++ b/django/contrib/auth/backends.py @@ -57,8 +57,7 @@ class ModelBackend(BaseBackend): Reject users with is_active=False. Custom user models that don't have that attribute are allowed. """ - is_active = getattr(user, "is_active", None) - return is_active or is_active is None + return getattr(user, "is_active", True) def _get_user_permissions(self, user_obj): return user_obj.user_permissions.all()