From 6648dc8de7efca538af444e964c551d0affc63f5 Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Sun, 4 May 2025 16:47:43 +0330 Subject: [PATCH] fix getting jwt fields from request --- apps/authentication/api/v1/serializers/jwt.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/authentication/api/v1/serializers/jwt.py b/apps/authentication/api/v1/serializers/jwt.py index ad7801f..4bff9f5 100644 --- a/apps/authentication/api/v1/serializers/jwt.py +++ b/apps/authentication/api/v1/serializers/jwt.py @@ -17,9 +17,11 @@ class CustomizedTokenObtainPairSerializer(TokenObtainPairSerializer): # noqa """ override validate method to add more conditions """ - captcha_code, captcha_key = attrs['captcha_code'], attrs['captcha_key'] - if captcha_code != cache.get(captcha_key) or captcha_code not in attrs.keys(): + captcha_code = self.context['request'].data['captcha_code'] + captcha_key = self.context['request'].data['captcha_key'] + + if captcha_code != cache.get(captcha_key) or captcha_code not in self.context['request'].data.keys(): raise captcha_exception.CaptchaFailed() data = super().validate(attrs)