TurTaskWeb/backend/authentications/serializers.py
2023-11-04 03:51:20 +07:00

12 lines
422 B
Python

from rest_framework_simplejwt.serializers import TokenObtainPairSerializer
class MyTokenObtainPairSerializer(TokenObtainPairSerializer):
@classmethod
def get_token(cls, user):
"""
Get the token for the user and add custom claims, such as 'username'.
"""
token = super(MyTokenObtainPairSerializer, cls).get_token(user)
token['username'] = user.username
return token