diff --git a/lib/towerops_web/user_auth.ex b/lib/towerops_web/user_auth.ex index 51564239..9c7cb5f0 100644 --- a/lib/towerops_web/user_auth.ex +++ b/lib/towerops_web/user_auth.ex @@ -340,8 +340,8 @@ defmodule ToweropsWeb.UserAuth do Plug to store the current path for LiveView routes. This runs in the pipeline before LiveView mount, allowing us to store - the return path in the session before on_mount callbacks run. Only stores - if there's no existing return path to avoid overwriting. + the return path in the session before on_mount callbacks run. Always + overwrites any existing return path to ensure sudo mode redirects work correctly. """ def store_return_to_for_liveview(conn, _opts) do # Skip authentication-related and public paths @@ -358,7 +358,6 @@ defmodule ToweropsWeb.UserAuth do should_store = conn.method == "GET" && - is_nil(get_session(conn, :user_return_to)) && !Enum.any?(skip_paths, &String.starts_with?(conn.request_path, &1)) && conn.request_path != "/" diff --git a/priv/static/changelog.txt b/priv/static/changelog.txt index 83b4b09c..3d21bea7 100644 --- a/priv/static/changelog.txt +++ b/priv/static/changelog.txt @@ -1,6 +1,7 @@ Devices Tested & Working * Mikrotik RB5009UG+S+, CCR1009-7G-1C-1S+, CCR2004-16G-2S+ * Ubiquiti AC, LTU, AirFiber +* Cambium ePMP 2026-01-31 * Small ui tweaks diff --git a/test/towerops_web/user_auth_test.exs b/test/towerops_web/user_auth_test.exs index d93aaff8..792b5bdb 100644 --- a/test/towerops_web/user_auth_test.exs +++ b/test/towerops_web/user_auth_test.exs @@ -1015,15 +1015,17 @@ defmodule ToweropsWeb.UserAuthTest do assert get_session(conn, :user_return_to) == "/devices" end - test "does not store if return_to already exists", %{conn: conn} do + test "overwrites existing return_to with new path", %{conn: conn} do conn = conn |> put_session(:user_return_to, "/original") |> Map.put(:request_path, "/new") + |> Map.put(:path_info, ["new"]) + |> Map.put(:query_string, "") |> Map.put(:method, "GET") |> UserAuth.store_return_to_for_liveview([]) - assert get_session(conn, :user_return_to) == "/original" + assert get_session(conn, :user_return_to) == "/new" end test "does not store POST requests", %{conn: conn} do