mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-12-19 06:30:13 +08:00
Fix issue with logging out from ZTA (#2953)
This commit is contained in:
parent
e49e06010a
commit
24b591825f
2 changed files with 22 additions and 10 deletions
|
|
@ -3,12 +3,29 @@ defmodule LivebookWeb.UserController do
|
||||||
|
|
||||||
def logout(conn, _params) do
|
def logout(conn, _params) do
|
||||||
if get_session(conn, :user_id) do
|
if get_session(conn, :user_id) do
|
||||||
conn
|
if Livebook.Config.logout_enabled?() do
|
||||||
|> configure_session(renew: true)
|
do_zta_logout(conn)
|
||||||
|> clear_session()
|
else
|
||||||
|> render("logout.html")
|
do_logout(conn)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
redirect(conn, to: ~p"/")
|
redirect(conn, to: ~p"/")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp do_logout(conn) do
|
||||||
|
conn
|
||||||
|
|> configure_session(renew: true)
|
||||||
|
|> clear_session()
|
||||||
|
|> render("logout.html")
|
||||||
|
end
|
||||||
|
|
||||||
|
defp do_zta_logout(conn) do
|
||||||
|
{_type, module, _key} = Livebook.Config.identity_provider()
|
||||||
|
|
||||||
|
case module.logout(LivebookWeb.ZTA, conn) do
|
||||||
|
:ok -> do_logout(conn)
|
||||||
|
{:error, reason} -> conn |> redirect(to: ~p"/") |> put_flash(:error, reason)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,7 @@ defmodule LivebookWeb.SidebarHook do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp handle_info(:logout, socket) do
|
defp handle_info(:logout, socket) do
|
||||||
{_type, module, _key} = Livebook.Config.identity_provider()
|
{:halt, redirect(socket, to: ~p"/logout")}
|
||||||
|
|
||||||
case module.logout(LivebookWeb.ZTA, socket) do
|
|
||||||
:ok -> {:halt, redirect(socket, to: ~p"/logout")}
|
|
||||||
{:error, reason} -> {:cont, put_flash(socket, :error, reason)}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@connection_events ~w(hub_connected hub_changed hub_deleted)a
|
@connection_events ~w(hub_connected hub_changed hub_deleted)a
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue