Geoffrey-Django/GeoffreyApp/api/key.py

17 lines
337 B
Python
Raw Normal View History

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