from GeoffreyApp.models import APIToken


def check_request_for_key(request):
    if "api" in request:
        key = request["api"]

        return APIToken.objects.get(key=key)

    return None


def check_key(key, **kwargs):
    if APIToken.objects.filter(key=key, **kwargs).exists():
        return True
    else:
        return False