yzk_wechat_event/utils/jwt.py

21 lines
574 B
Python
Raw Normal View History

2023-12-13 11:41:22 +08:00
def jwt_response_payload_handler(token, user=None, request=None):
"""
Returns the response data for both the login and refresh views.
Override to return a custom response such as including the
serialized representation of the User.
Example:
def jwt_response_payload_handler(token, user=None, request=None):
return {
'token': token,
'user': UserSerializer(user, context={'request': request}).data
}
"""
return {
'id': user.id,
'token': token,
'username': user.username,
}