mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-27 13:56:21 +08:00
* Get user identity * Moves current_user_id to identity_data * Renames cookies to session_identity * Keep zta keys in the state * User id from GoogleIap * Update cloudflare.ex * Update googleiap.ex * Email only for ZTA * Get the current_user_id from the identity_data * Applying suggestions * Applying suggestions * Fix verify_token --------- Co-authored-by: José Valim <jose.valim@gmail.com>
19 lines
499 B
Elixir
19 lines
499 B
Elixir
defmodule LivebookWeb.SessionIdentity do
|
|
# This module implements the ZTA contract specific to Livebook cookies
|
|
@moduledoc false
|
|
|
|
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
|