mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-01-07 23:47:53 +08:00
550869c356
* Fix GoogleIAP certs and fields * Email as name when name is not available * Initial docs * Update lib/livebook_web/live/hooks/user_hook.ex Co-authored-by: José Valim <jose.valim@gmail.com> --------- Co-authored-by: José Valim <jose.valim@gmail.com>
19 lines
499 B
Elixir
19 lines
499 B
Elixir
defmodule LivebookWeb.SessionIdentity do
|
|
@moduledoc false
|
|
# This module implements the ZTA contract specific to Livebook cookies
|
|
|
|
import Plug.Conn
|
|
|
|
def authenticate(_, conn, _) do
|
|
if id = get_session(conn, :current_user_id) do
|
|
{conn, %{id: id}}
|
|
else
|
|
user_id = Livebook.Utils.random_id()
|
|
{put_session(conn, :current_user_id, user_id), %{id: user_id}}
|
|
end
|
|
end
|
|
|
|
def child_spec(_opts) do
|
|
%{id: __MODULE__, start: {Function, :identity, [:ignore]}}
|
|
end
|
|
end
|