from flask import request
from itsdangerous import Serializer
from itsdangerous.exc import BadSignature
from app import app


def is_vandal():
    """ Return True if the current user looks like a vandal """
    s = Serializer(app.config["SECRET_KEY"])

    vandal_token = request.cookies.get('vandale')
    if vandal_token is None:
        return False

    try:
        s.loads(vandal_token)
    except BadSignature:
        return False

    return True
