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.
22 lines
510 B
Elixir
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
|