user setting re-auth redirect hopeful fix
This commit is contained in:
parent
4bcac595ad
commit
c690827ee0
3 changed files with 7 additions and 5 deletions
|
|
@ -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 != "/"
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue