def jwt_payload_handler(user):
    """
    A custom JWT Payload Handler that adds certain extra data in
    payload such as: email, mobile, name

    Source: Himanshu Shankar (https://github.com/iamhssingh)
    Parameters
    ----------
    user: get_user_model()

    Returns
    -------
    payload: dict
    """
    import uuid
    from calendar import timegm
    from datetime import datetime
    from rest_framework_jwt.compat import get_username
    from rest_framework_jwt.compat import get_username_field
    from rest_framework_jwt.settings import api_settings
    username_field = get_username_field()
    username = get_username(user)
    payload = {'user_id': user.pk, 'is_admin': user.is_staff, 'exp': 
        datetime.utcnow() + api_settings.JWT_EXPIRATION_DELTA}
    if hasattr(user, 'email'):
        payload['email'] = user.email
    if hasattr(user, 'mobile'):
        payload['mobile'] = user.mobile
    if hasattr(user, 'name'):
        payload['name'] = user.name
    if isinstance(user.pk, uuid.UUID):
        payload['user_id'] = str(user.pk)
    payload[username_field] = username
    if api_settings.JWT_ALLOW_REFRESH:
        payload['orig_iat'] = timegm(datetime.utcnow().utctimetuple())
    if api_settings.JWT_AUDIENCE is not None:
        payload['aud'] = api_settings.JWT_AUDIENCE
    if api_settings.JWT_ISSUER is not None:
        payload['iss'] = api_settings.JWT_ISSUER
    return payload
