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

View Source

Generates a verification form for TOTP two-factor authentication.

This component supports two authentication flows:

Token-based Flow (mode: :token)

Used after primary authentication (e.g., password sign-in) when the user has TOTP enabled. The token contains partial authentication info that will be exchanged for a full session token after TOTP verification.

Step-up Authentication Flow (mode: :step_up)

Used when an already-authenticated user needs to verify their TOTP code to access protected resources. No token is required - uses the current_user from the session.

Component hierarchy

This is rendered by AshAuthentication.Phoenix.TotpVerifyLive.

Children:

Props

  • strategy - The TOTP strategy configuration. Required.
  • mode - The verification mode: :token, :step_up, or :error. Required.
  • token - The partial authentication token (required for :token mode).
  • current_user - The authenticated user (required for :step_up mode).
  • 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.
  • :label_text - Text for the form heading.
  • :instructions_class - CSS class for instructions text.
  • :instructions_text - Instructions text shown above the code input.
  • :error_class - CSS class for error messages.
  • :sign_in_link_class - CSS class for the sign-in link when not authenticated.
  • :sign_in_link_text - Text for the sign-in link.
  • :recovery_code_link_class - CSS class for the recovery code link.
  • :recovery_code_link_text - Text for the link to recovery code verification (or nil to hide).
  • :recovery_code_link_path - Path to the recovery code verification page (or nil to hide the link).

See AshAuthentication.Phoenix.Overrides for more information.

Summary

Types

props()

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