From 4edb8881357e043fd7ea15efeb2d592c9fb55efc Mon Sep 17 00:00:00 2001 From: Justin Choquette <jchoquette@iol.unh.edu> Date: Tue, 7 Jun 2022 16:07:54 -0400 Subject: Laas Dashboard Front End Improvements Change-Id: Ib9aa21747bd57faef94db7795cd89119ad4b0a9d Signed-off-by: Justin Choquette <jchoquette@iol.unh.edu> --- src/api/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/api/views.py') diff --git a/src/api/views.py b/src/api/views.py index 1516374..ffa9b3f 100644 --- a/src/api/views.py +++ b/src/api/views.py @@ -430,7 +430,11 @@ def auth_and_log(request, endpoint): token = Token.objects.get(key=user_token) except Token.DoesNotExist: token = None - response = HttpResponse('Unauthorized', status=401) + # Added logic to detect malformed token + if len(str(user_token)) != 40: + response = HttpResponse('Malformed Token', status=401) + else: + response = HttpResponse('Unauthorized', status=401) x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') if x_forwarded_for: -- cgit 1.2.3-korg