From 3e062aed360ca54c26733b175d00d0d4671f3591 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sun, 11 Dec 2022 00:25:48 -0700 Subject: Timelines working --- api/decorators.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 api/decorators.py (limited to 'api/decorators.py') diff --git a/api/decorators.py b/api/decorators.py new file mode 100644 index 0000000..b60cc05 --- /dev/null +++ b/api/decorators.py @@ -0,0 +1,19 @@ +from functools import wraps + +from django.http import JsonResponse + + +def identity_required(function): + """ + API version of the identity_required decorator that just makes sure the + token is tied to one, not an app only. + """ + + @wraps(function) + def inner(request, *args, **kwargs): + # They need an identity + if not request.identity: + return JsonResponse({"error": "identity_token_required"}, status=400) + return function(request, *args, **kwargs) + + return inner -- cgit v1.2.3