mirror of
https://github.com/TurTaskProject/TurTaskWeb.git
synced 2025-12-18 21:44:07 +01:00
12 lines
422 B
Python
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 |