livebook/lib/livebook_web/live/hooks/auth_hook.ex
Jonatan Kłosko ccc64876a8
Add support for widget binary payloads (#982)
* Add support for widget binary payloads

* Migrate LV auth to a separate hook

* Properly set user buffer when encoding
2022-02-07 21:03:25 +01:00

14 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