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