From dc32e16c681863efb1da13b4f50f1296fd62c4d5 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sun, 25 Jan 2026 11:15:19 -0600 Subject: [PATCH] fix: allow cloud pollers to access devices from any organization Cloud pollers (is_cloud_poller = true, organization_id = nil) were being blocked from polling devices because verify_device_organization was checking if the device's organization matched the agent's organization. Since cloud pollers don't belong to any organization (organization_id is nil), they should be allowed to poll devices from any organization. Changes: - verify_device_organization now allows access if organization_id is nil - This fixes "Device not in agent's organization" errors for cloud pollers Error before: Device b7e8dd99-0b19-496d-97ae-9f2601d16464 not in agent's organization --- lib/towerops_web/channels/agent_channel.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/towerops_web/channels/agent_channel.ex b/lib/towerops_web/channels/agent_channel.ex index fa41b1f2..130e2e3c 100644 --- a/lib/towerops_web/channels/agent_channel.ex +++ b/lib/towerops_web/channels/agent_channel.ex @@ -330,7 +330,8 @@ defmodule ToweropsWeb.AgentChannel do end defp verify_device_organization(device, organization_id) do - if device.site.organization_id == organization_id do + # Cloud pollers (organization_id = nil) can access any device + if is_nil(organization_id) or device.site.organization_id == organization_id do :ok else {:error, :wrong_organization}