2022-01-06 23:31:26 +08:00
|
|
|
defmodule LivebookWeb.Socket do
|
|
|
|
use Phoenix.Socket
|
|
|
|
|
2022-02-28 20:53:33 +08:00
|
|
|
channel "js_view", LivebookWeb.JSViewChannel
|
2022-01-06 23:31:26 +08:00
|
|
|
|
|
|
|
@impl true
|
2022-02-08 04:03:25 +08:00
|
|
|
def connect(_params, socket, info) do
|
2023-02-18 08:16:42 +08:00
|
|
|
# The session is present only if the CSRF token is valid. We rely
|
|
|
|
# on CSRF token, because we don't check connection origin as noted
|
|
|
|
# in LivebookWeb.Endpoint.
|
|
|
|
if info.session do
|
2022-02-08 04:03:25 +08:00
|
|
|
{:ok, socket}
|
2022-01-06 23:31:26 +08:00
|
|
|
else
|
|
|
|
:error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@impl true
|
2022-02-08 04:03:25 +08:00
|
|
|
def id(_socket), do: nil
|
2022-01-06 23:31:26 +08:00
|
|
|
end
|