From 90ded41608349aba28289be8ec3c1e577e04489c Mon Sep 17 00:00:00 2001 From: Mehdi Mirzaei Date: Wed, 14 Jun 2023 13:29:29 +0330 Subject: [PATCH 1/4] Update serializers.py --- rest_framework_simplejwt/serializers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rest_framework_simplejwt/serializers.py b/rest_framework_simplejwt/serializers.py index e75e709c9..26e0878de 100644 --- a/rest_framework_simplejwt/serializers.py +++ b/rest_framework_simplejwt/serializers.py @@ -53,6 +53,10 @@ def validate(self, attrs: Dict[str, Any]) -> Dict[Any, Any]: self.user = authenticate(**authenticate_kwargs) + if not user: + msg = _('Unable to log in with provided credentials.') + raise serializers.ValidationError(msg, code='authorization') + if not api_settings.USER_AUTHENTICATION_RULE(self.user): raise exceptions.AuthenticationFailed( self.error_messages["no_active_account"], From 289fa30c9fb0405e31ed0c3154567b832aeb353b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 14 Jun 2023 10:03:56 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- rest_framework_simplejwt/serializers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rest_framework_simplejwt/serializers.py b/rest_framework_simplejwt/serializers.py index 26e0878de..515f9a14d 100644 --- a/rest_framework_simplejwt/serializers.py +++ b/rest_framework_simplejwt/serializers.py @@ -54,8 +54,8 @@ def validate(self, attrs: Dict[str, Any]) -> Dict[Any, Any]: self.user = authenticate(**authenticate_kwargs) if not user: - msg = _('Unable to log in with provided credentials.') - raise serializers.ValidationError(msg, code='authorization') + msg = _("Unable to log in with provided credentials.") + raise serializers.ValidationError(msg, code="authorization") if not api_settings.USER_AUTHENTICATION_RULE(self.user): raise exceptions.AuthenticationFailed( From 8f82eaf7d9f4f769eaf0547bcc224657ad08ffbf Mon Sep 17 00:00:00 2001 From: Mehdi Mirzaei Date: Wed, 14 Jun 2023 13:41:44 +0330 Subject: [PATCH 3/4] Update serializers.py --- rest_framework_simplejwt/serializers.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rest_framework_simplejwt/serializers.py b/rest_framework_simplejwt/serializers.py index 515f9a14d..e8fc350e4 100644 --- a/rest_framework_simplejwt/serializers.py +++ b/rest_framework_simplejwt/serializers.py @@ -53,9 +53,7 @@ def validate(self, attrs: Dict[str, Any]) -> Dict[Any, Any]: self.user = authenticate(**authenticate_kwargs) - if not user: - msg = _("Unable to log in with provided credentials.") - raise serializers.ValidationError(msg, code="authorization") + test = 1 if not api_settings.USER_AUTHENTICATION_RULE(self.user): raise exceptions.AuthenticationFailed( From 84acbc5cd4a13da8b6928d5ce666edefe9374bab Mon Sep 17 00:00:00 2001 From: Mehdi Mirzaei Date: Wed, 14 Jun 2023 13:50:55 +0330 Subject: [PATCH 4/4] Update serializers.py --- rest_framework_simplejwt/serializers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rest_framework_simplejwt/serializers.py b/rest_framework_simplejwt/serializers.py index e8fc350e4..515f9a14d 100644 --- a/rest_framework_simplejwt/serializers.py +++ b/rest_framework_simplejwt/serializers.py @@ -53,7 +53,9 @@ def validate(self, attrs: Dict[str, Any]) -> Dict[Any, Any]: self.user = authenticate(**authenticate_kwargs) - test = 1 + if not user: + msg = _("Unable to log in with provided credentials.") + raise serializers.ValidationError(msg, code="authorization") if not api_settings.USER_AUTHENTICATION_RULE(self.user): raise exceptions.AuthenticationFailed(