From 129bc9a8f492d85ed4b06d1da60af2d7b62720b1 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Wed, 4 Feb 2026 18:25:48 -0600 Subject: [PATCH] fix: handle nil site in graph_live access check Similar to previous fix - use device.organization_id directly instead of device.site.organization_id to avoid BadMapError when device has no site. --- lib/towerops_web/live/graph_live/show.ex | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/towerops_web/live/graph_live/show.ex b/lib/towerops_web/live/graph_live/show.ex index 45af36cf..4042890d 100644 --- a/lib/towerops_web/live/graph_live/show.ex +++ b/lib/towerops_web/live/graph_live/show.ex @@ -28,10 +28,8 @@ defmodule ToweropsWeb.GraphLive.Show do |> push_navigate(to: ~p"/devices")} device -> - # Preload site and organization to check access - device = Repo.preload(device, site: :organization) - - if device.site.organization_id == organization.id do + # Check if device belongs to current organization + if device.organization_id == organization.id do maybe_subscribe_to_device(socket, device_id) range = Map.get(params, "range", "24h")