Skip to content

Commit

Permalink
Merge bdf034e into 996a1c5
Browse files Browse the repository at this point in the history
  • Loading branch information
eelectronn committed Jan 14, 2021
2 parents 996a1c5 + bdf034e commit 8368e61
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions rest_social_auth/serializers.py
Expand Up @@ -6,6 +6,15 @@
from rest_framework.authtoken.models import Token


# Finding fields to be excluded from User Serializer
User = get_user_model()
user_fields = set([field.name for field in User._meta.get_fields()])
fields_to_exclude = {'is_staff', 'is_active', 'date_joined', 'password', 'last_login',
'user_permissions', 'groups', 'is_superuser'}
fields_to_exclude &= user_fields
fields_to_exclude = tuple(fields_to_exclude)


class OAuth2InputSerializer(serializers.Serializer):

provider = serializers.CharField(required=False)
Expand All @@ -24,10 +33,7 @@ class UserSerializer(serializers.ModelSerializer):

class Meta:
model = get_user_model()
exclude = (
'is_staff', 'is_active', 'date_joined', 'password', 'last_login', 'user_permissions',
'groups', 'is_superuser',
)
exclude = fields_to_exclude


class TokenSerializer(serializers.Serializer):
Expand Down

0 comments on commit 8368e61

Please sign in to comment.