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

This commit is contained in:
DJ Gillespie 2024-03-05 14:20:54 -07:00
parent 8bdbc05c59
commit 6ec9065f8e

View File

@ -41,9 +41,13 @@ class ConnectionViewSet(viewsets.ModelViewSet):
account_id = request.data.get("account")
public_token = request.data.get("public_token")
user = request.user
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,