AshAuthentication.Phoenix.Components.Totp.SetupForm (ash_authentication_phoenix v3.0.0-rc.6)

View Source

Generates a setup form for TOTP authentication with QR code display.

This component handles the complete TOTP setup flow:

  1. Shows a "Set up" button
  2. When clicked, calls the setup action to generate a secret
  3. Displays the QR code and code input field
  4. Validates the code (format only for confirmation mode)
  5. Confirms setup when user submits valid code

Requirements

This component requires the eqrcode library for QR code generation. Add it to your dependencies:

{:eqrcode, "~> 0.1"}

Component hierarchy

This is a child of AshAuthentication.Phoenix.Components.Totp.

Children:

Props

  • strategy - The configuration map as per AshAuthentication.Info.strategy/2. Required.
  • label - The text to show in the submit label. Generated from the configured action name (via Phoenix.Naming.humanize/1) if not supplied. Set to false to disable.
  • overrides - A list of override modules.
  • gettext_fn - Optional text translation function.

Overrides

This component provides the following overrides:

  • :root_class - CSS class for the root div element.
  • :slot_class - CSS class for the div surrounding the slot.
  • :form_class - CSS class for the form element.
  • :button_text - Text for the submit button.
  • :disable_button_text - Text for the submit button when the request is happening.
  • :label_class - CSS class for the h2 element.
  • :instructions_class - CSS class for setup instructions text.
  • :instructions_text - Instructions text shown above QR code.
  • :error_class - CSS class for error messages.
  • :qr_code_class - CSS class for the QR code container.
  • :qr_code_wrapper_class - CSS class for the wrapper around QR code and instructions.
  • :setup_button_text - Text for the initial setup button.
  • :setup_button_class - CSS class for the initial setup button.

See AshAuthentication.Phoenix.Overrides for more information.

Summary

Types

props()

@type props() :: %{
  :strategy => AshAuthentication.Strategy.t(),
  optional(:label) => String.t() | false,
  optional(:current_tenant) => String.t(),
  optional(:context) => map(),
  optional(:auth_routes_prefix) => String.t(),
  optional(:overrides) => [module()],
  optional(:gettext_fn) => {module(), atom()}
}