Check if CUPS is allowd by token

def check_cups_allowed(func):
    """Check if CUPS is allowd by token
    """
    @wraps(func)
    def decorator(*args, **kwargs):
        cups = kwargs.get('cups')
        if (cups and current_user.is_authenticated()
                and not current_user.allowed(cups, 'cups')):
            return current_app.login_manager.unauthorized()
        return func(*args, **kwargs)
    return decorator