Fix JWTSerializer USER_DETAILS_SERIALIZER import

Related to #30
This commit is contained in:
Jonathan Henrique Maia de Moraes 2020-04-03 14:50:02 -03:00
parent f2a507802d
commit 3304a6b3d3
No known key found for this signature in database
GPG Key ID: 97DC299CE67ABB18

View File

@ -4,6 +4,7 @@ from django.contrib.auth.forms import PasswordResetForm, SetPasswordForm
from django.contrib.auth.tokens import default_token_generator from django.contrib.auth.tokens import default_token_generator
from django.utils.encoding import force_text from django.utils.encoding import force_text
from django.utils.http import urlsafe_base64_decode as uid_decoder from django.utils.http import urlsafe_base64_decode as uid_decoder
from django.utils.module_loading import import_string
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from rest_framework import exceptions, serializers from rest_framework import exceptions, serializers
from rest_framework.exceptions import ValidationError from rest_framework.exceptions import ValidationError
@ -145,7 +146,14 @@ class JWTSerializer(serializers.Serializer):
JWTSerializer. Defining it here to avoid circular imports JWTSerializer. Defining it here to avoid circular imports
""" """
rest_auth_serializers = getattr(settings, 'REST_AUTH_SERIALIZERS', {}) rest_auth_serializers = getattr(settings, 'REST_AUTH_SERIALIZERS', {})
JWTUserDetailsSerializer = rest_auth_serializers.get('USER_DETAILS_SERIALIZER', UserDetailsSerializer)
JWTUserDetailsSerializer = import_string(
rest_auth_serializers.get(
'USER_DETAILS_SERIALIZER',
'dj_rest_auth.serializers.UserDetailsSerializer'
)
)
user_data = JWTUserDetailsSerializer(obj['user'], context=self.context).data user_data = JWTUserDetailsSerializer(obj['user'], context=self.context).data
return user_data return user_data