defmodule PhoenixKitWeb.Components.OAuthButtons do @moduledoc """ OAuth authentication buttons component for Google and Apple Sign-In. This component automatically checks if OAuth is available and configured. If OAuth is not available (dependencies not installed or not enabled in settings), the buttons will not be rendered. """ use Phoenix.Component alias PhoenixKit.Users.OAuthAvailability alias PhoenixKit.Utils.Routes alias PhoenixKitWeb.Components.Core.Icons @doc """ Renders OAuth provider buttons for authentication. This component only renders buttons if: - OAuth is enabled in settings (oauth_enabled = true) - Ueberauth library is loaded - At least one provider is configured ## Examples <.oauth_buttons /> <.oauth_buttons show_divider={false} /> <.oauth_buttons class="mt-6" /> """ attr :class, :string, default: "" attr :show_divider, :boolean, default: true def oauth_buttons(assigns) do # Check each provider individually assigns = assigns |> assign(:google_enabled, OAuthAvailability.provider_enabled?(:google)) |> assign(:apple_enabled, OAuthAvailability.provider_enabled?(:apple)) |> assign(:github_enabled, OAuthAvailability.provider_enabled?(:github)) |> assign(:facebook_enabled, OAuthAvailability.provider_enabled?(:facebook)) # Check if at least one provider is enabled any_provider_enabled = assigns.google_enabled or assigns.apple_enabled or assigns.github_enabled or assigns.facebook_enabled assigns = assign(assigns, :any_provider_enabled, any_provider_enabled) ~H""" <%= if @any_provider_enabled do %>