Make login not required to access available API

This commit is contained in:
Erin 2023-10-20 15:03:07 -07:00
parent ff44ee2f1e
commit 9c7bbd31ec
No known key found for this signature in database
GPG key ID: 1CAD275313C62460

View file

@ -5,6 +5,8 @@ from django.http import JsonResponse
import requests import requests
from login_required import login_not_required
from cachetools.func import ttl_cache from cachetools.func import ttl_cache
@ -58,14 +60,18 @@ def check_domain_available(domain):
a match. a match.
""" """
Domain = apps.get_model("registrar.Domain") Domain = apps.get_model("registrar.Domain")
if domain.endswith(".gov"): try:
return Domain.available(domain) if domain.endswith(".gov"):
else: return Domain.available(domain)
# domain search string doesn't end with .gov, add it on here else:
return Domain.available(domain + ".gov") # domain search string doesn't end with .gov, add it on here
return Domain.available(domain + ".gov")
except:
return False
@require_http_methods(["GET"]) @require_http_methods(["GET"])
@login_not_required
def available(request, domain=""): def available(request, domain=""):
"""Is a given domain available or not. """Is a given domain available or not.