towerops/lib/towerops_web/live/org_live/index.ex
Graham McIntire c56496f7cc
fix: org switching now correctly updates session
The select_org LiveView event was updating default_organization_id in
the database but not the session's current_organization_id. Since
load_default_organization prioritizes the session value, users would
always get redirected back to the stale org.

Replaced with a controller POST action that updates both the session
and DB default before redirecting.
2026-03-04 17:04:49 -06:00

22 lines
510 B
Elixir

defmodule ToweropsWeb.OrgLive.Index do
@moduledoc false
use ToweropsWeb, :live_view
alias Towerops.Organizations
@impl true
def mount(_params, _session, socket) do
user = socket.assigns.current_scope.user
organizations = Organizations.list_user_organizations(user.id)
{:ok,
socket
|> assign(:page_title, t("Your Organizations"))
|> assign(:organizations, organizations)}
end
@impl true
def handle_params(_params, _url, socket) do
{:noreply, socket}
end
end