def jwt_response_payload_handler(token, user=None, request=None, role=None): if user.username: name = user.username else: name = user.username return { "authenticated": True, 'id': user.id, "role": role, 'name': name, 'username': user.username, 'token': token, }