def token_auth(token) -> bool:
    ' HTTP bearer token authorization '
    jwt = JWT(current_app.config['SECRET_KEY'])
    try:
        data = jwt.loads(token)
    except Exception:
        raise AuthFailed(field='token')
    if data.get('consumer_id'):
        ...
    else:
        if (('user_id' or 'role_id') not in data):
            raise AuthFailed(field='token')
        if ((data['role_id'] != 1) and (not data.get('tenant_uid'))):
            raise AuthFailed(field='token')
        user = User.query.filter((User.roleIntID == data['role_id']), (User.id == data['user_id']), (User.tenantID == data['tenant_uid'])).first()
        if (not user):
            raise AuthFailed(field='token')
        g.user_id: int = user.id
        g.tenant_uid: str = user.tenantID
        g.role_id: int = user.roleIntID
        g.app_uid: str = None
        g.user_auth_type: int = user.userAuthType
        user.lastRequestTime = arrow.now().naive
        user.update()
    return True
HTTP bearer token authorization
def token_auth(token) -> bool:
    '  '
    jwt = JWT(current_app.config['SECRET_KEY'])
    try:
        data = jwt.loads(token)
    except Exception:
        raise AuthFailed(field='token')
    if data.get('consumer_id'):
        ...
    else:
        if (('user_id' or 'role_id') not in data):
            raise AuthFailed(field='token')
        if ((data['role_id'] != 1) and (not data.get('tenant_uid'))):
            raise AuthFailed(field='token')
        user = User.query.filter((User.roleIntID == data['role_id']), (User.id == data['user_id']), (User.tenantID == data['tenant_uid'])).first()
        if (not user):
            raise AuthFailed(field='token')
        g.user_id: int = user.id
        g.tenant_uid: str = user.tenantID
        g.role_id: int = user.roleIntID
        g.app_uid: str = None
        g.user_auth_type: int = user.userAuthType
        user.lastRequestTime = arrow.now().naive
        user.update()
    return True