Catch missing API key field
This commit is contained in:
parent
12e6d64b37
commit
44db5af9a8
1 changed files with 1 additions and 1 deletions
|
@ -26,7 +26,7 @@ class APIView(View):
|
|||
def dispatch(self, request, *args, **kwargs):
|
||||
try:
|
||||
APIKey.objects.get(key=request.headers["apikey"])
|
||||
except APIKey.DoesNotExist:
|
||||
except (APIKey.DoesNotExist, KeyError):
|
||||
return JsonResponse({"error": "No valid API key provided"})
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
|
|
Loading…
Reference in a new issue