defmodule LivebookWeb.AppAuthLive do use LivebookWeb, :live_view @impl true def mount(%{"slug" => slug} = params, _session, socket) when not socket.assigns.app_authenticated? do {:ok, assign(socket, slug: slug, authenticated_path: authenticated_path(params), password: "", errors: [] )} end def mount(params, _session, socket) do {:ok, push_navigate(socket, to: authenticated_path(params))} end defp authenticated_path(%{"slug" => slug, "id" => id}), do: ~p"/apps/#{slug}/sessions/#{id}" defp authenticated_path(%{"slug" => slug}), do: ~p"/apps/#{slug}" @impl true def render(assigns) do ~H"""