From 0c9860623495f202a4bbc6bfb15bba428d4b0a0d Mon Sep 17 00:00:00 2001 From: DJ Gillespie Date: Tue, 5 Mar 2024 14:27:20 -0700 Subject: [PATCH] add manual account override for when unauthenticated users call the auth endpoint. --- connection/views.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/connection/views.py b/connection/views.py index 034ae24..4eecff1 100644 --- a/connection/views.py +++ b/connection/views.py @@ -47,7 +47,7 @@ class ConnectionViewSet(viewsets.ModelViewSet): else: accounts = (Account.objects.filter(pk=account_id, owner=user) | Account.objects.filter(pk=account_id, - admin_users__in=[user])) + admin_users__in=[user])) if not accounts: return Response( status=status.HTTP_400_BAD_REQUEST, @@ -98,9 +98,12 @@ class ConnectionViewSet(viewsets.ModelViewSet): user = request.user # Filter out any accounts with the right id, but the given user # is not an owner or admin on that account. - accounts = (Account.objects.filter(pk=account_id, owner=user) | - Account.objects.filter(pk=account_id, - admin_users__in=[user])) + if request.user.is_anonymous(): + accounts = (Account.objects.filter(pk=1)) + else: + accounts = (Account.objects.filter(pk=account_id, owner=user) | + Account.objects.filter(pk=account_id, + admin_users__in=[user])) if not accounts: return Response( status=status.HTTP_400_BAD_REQUEST,