mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-11-17 05:18:52 +08:00
15 lines
355 B
Elixir
15 lines
355 B
Elixir
|
defmodule LivebookWeb.AuthHook do
|
||
|
import Phoenix.LiveView
|
||
|
|
||
|
def on_mount(:default, _params, session, socket) do
|
||
|
uri = get_connect_info(socket, :uri)
|
||
|
auth_mode = Livebook.Config.auth_mode()
|
||
|
|
||
|
if LivebookWeb.AuthPlug.authenticated?(session || %{}, uri.port, auth_mode) do
|
||
|
{:cont, socket}
|
||
|
else
|
||
|
{:halt, socket}
|
||
|
end
|
||
|
end
|
||
|
end
|