fix: always redirect to /devices when stopping impersonation

Previously redirected to /dashboard or /orgs based on whether the
superuser had organizations. Now always goes to /devices for
consistency.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Graham McIntire 2026-02-08 14:01:15 -06:00
parent 039bce3938
commit cbff651f83
No known key found for this signature in database

View file

@ -883,13 +883,6 @@ defmodule ToweropsWeb.UserAuth do
ip_address: ip
})
# Dashboard page
redirect_path =
case Towerops.Organizations.list_user_organizations(superuser.id) do
[_first_org | _] -> ~p"/dashboard"
[] -> ~p"/orgs"
end
conn
|> delete_session(:superuser_id)
|> delete_session(:target_user_id)
@ -897,7 +890,7 @@ defmodule ToweropsWeb.UserAuth do
|> assign(:current_scope, Scope.for_user(superuser))
|> maybe_set_default_organization(superuser)
|> put_flash(:info, t_admin("Stopped impersonating"))
|> redirect(to: redirect_path)
|> redirect(to: ~p"/devices")
end
## Login tracking helpers