From 8f16c5ddc7305e642b81c20af8284eb9fef5d3f2 Mon Sep 17 00:00:00 2001 From: Peter Bassem Sobhi Date: Sun, 28 Jan 2018 00:50:15 +0200 Subject: [PATCH] Add settings attribute to check if inactive user login is allowed This will help if 'AllowAllUsersModelBackend' is used or any other authentication backend that allow inactive user login is used. --- rest_auth/serializers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rest_auth/serializers.py b/rest_auth/serializers.py index 45729b2..448e814 100644 --- a/rest_auth/serializers.py +++ b/rest_auth/serializers.py @@ -91,7 +91,8 @@ class LoginSerializer(serializers.Serializer): # Did we get back an active user? if user: - if not user.is_active: + # Raises error only if user is deactivated and inactive user login is disabled + if not user.is_active and not getattr(settings, 'REST_INACTIVE_USER_LOGIN', False): msg = _('User account is disabled.') raise exceptions.ValidationError(msg) else: