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.
This commit is contained in:
Graham McIntire 2026-02-04 18:25:48 -06:00
parent 95c6f53d15
commit 129bc9a8f4
No known key found for this signature in database

View file

@ -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")