add manual account override for when unauthenticated users call the auth endpoint.

This commit is contained in:
DJ Gillespie 2024-03-05 14:27:20 -07:00
parent 6ec9065f8e
commit 0c98606234

View File

@ -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,