defmodule HiveWeb.PageHTML do @moduledoc false use HiveWeb, :html alias Hive.Auth alias HiveWeb.Layouts def login_page(conn, opts) do assigns = %{ conn: conn, error: Keyword.get(opts, :error), product_name: Auth.product_name(), auth_enabled?: Auth.private?(), providers: Auth.providers() } ~H"""
{@product_name}

Log in to {@product_name}

<.alert :if={@error} status="error" size="medium" title={@error} />
<.button :for={{key, meta} <- @providers} label={"Continue with #{meta.display_name}"} href={~p"/auth/#{Atom.to_string(key)}"} variant="secondary" size="medium" /> <.button :if={!@auth_enabled?} label="Continue without signing in" href={~p"/"} variant="secondary" size="medium" />
<.alert status="warning" size="large" title="No identity provider is configured" description="Set HIVE_GOOGLE_CLIENT_ID/HIVE_GOOGLE_CLIENT_SECRET or HIVE_OIDC_ISSUER + HIVE_OIDC_CLIENT_ID/HIVE_OIDC_CLIENT_SECRET to enable login." />
<.alert status="information" size="large" title="This instance is public" description="Anyone can use it without signing in. Set HIVE_VISIBILITY=private and configure an identity provider to require login." /> <.button label="Continue without signing in" href={~p"/"} variant="secondary" size="medium" />
""" end def app_page(conn) do user = Auth.current_user(conn) || %{"name" => "Guest", "email" => nil} user_name = user["name"] || user["email"] || "Guest" assigns = %{ conn: conn, auth_enabled?: Auth.private?(), csrf_token: Plug.CSRFProtection.get_csrf_token(), product_name: Auth.product_name(), user_email: user["email"], user_name: user_name, avatar_color: if(user_name == "Guest", do: "gray", else: "purple"), current_path: conn.request_path } ~H"""

Overview

<.card icon="checkup_list" title="Getting started"> <.card_section>
""" end end