AshAuthentication.Phoenix.Components.Otp.Input (ash_authentication_phoenix v3.0.0-rc.6)

View Source

Function components for dealing with form input during OTP authentication.

Component hierarchy

These function components are consumed by AshAuthentication.Phoenix.Components.Otp.RequestForm and AshAuthentication.Phoenix.Components.Otp.VerifyForm.

Overrides

This component provides the following overrides:

  • :identity_input_label - Label for the identity field.
  • :identity_input_placeholder - Placeholder for the identity field.
  • :field_class - CSS class for div elements surrounding the fields.
  • :label_class - CSS class for label elements.
  • :input_class - CSS class for text/code input elements.
  • :submit_class - CSS class for the form submit input element.
  • :error_ul - CSS class for the ul element on error lists.
  • :error_li - CSS class for the li elements on error lists.
  • :input_class_with_error - CSS class for text/code input elements when there is a validation error.
  • :input_debounce - Number of milliseconds to debounce input by (or nil to disable).
  • :code_input_label - Label for the OTP code field.
  • :code_input_placeholder - Placeholder for the OTP code field.
  • :request_label - A function that takes the strategy and returns the request submit button text, or a string.
  • :verify_label - A function that takes the strategy and returns the verify submit button text, or a string.

See AshAuthentication.Phoenix.Overrides for more information.

Summary

Functions

Generate a form field for the OTP code.

Generate a form field for the configured identity field.

Generate a form submit button.

Functions

code_field(assigns)

@spec code_field(%{
  :socket => Phoenix.LiveView.Socket.t(),
  :strategy => AshAuthentication.Strategy.t(),
  :form => AshPhoenix.Form.t(),
  optional(:overrides) => [module()],
  optional(:gettext_fn) => {module(), atom()}
}) :: Phoenix.LiveView.Rendered.t() | no_return()

Generate a form field for the OTP code.

Props

  • socket - Phoenix LiveView socket. Required.
  • strategy - The configuration map as per AshAuthentication.Info.strategy/2. Required.
  • form - An AshPhoenix.Form. Required.
  • overrides - A list of override modules.
  • gettext_fn - Optional text translation function.

identity_field(assigns)

@spec identity_field(%{
  :socket => Phoenix.LiveView.Socket.t(),
  :strategy => AshAuthentication.Strategy.t(),
  :form => AshPhoenix.Form.t(),
  optional(:input_type) => :text | :email,
  optional(:overrides) => [module()],
  optional(:gettext_fn) => {module(), atom()}
}) :: Phoenix.LiveView.Rendered.t() | no_return()

Generate a form field for the configured identity field.

Props

  • socket - Phoenix LiveView socket. Required.
  • strategy - The configuration map as per AshAuthentication.Info.strategy/2. Required.
  • form - An AshPhoenix.Form. Required.
  • input_type - Either :text or :email. If not set, guessed from the identity field name.
  • overrides - A list of override modules.
  • gettext_fn - Optional text translation function.

submit(assigns)

@spec submit(%{
  :socket => Phoenix.LiveView.Socket.t(),
  :strategy => AshAuthentication.Strategy.t(),
  :form => AshPhoenix.Form.t(),
  :action => :request | :verify,
  optional(:label) => String.t(),
  optional(:disable_text) => String.t(),
  optional(:overrides) => [module()],
  optional(:gettext_fn) => {module(), atom()}
}) :: Phoenix.LiveView.Rendered.t() | no_return()

Generate a form submit button.

Props

  • socket - Phoenix LiveView socket. Required.
  • strategy - The configuration map as per AshAuthentication.Info.strategy/2. Required.
  • form - An AshPhoenix.Form. Required.
  • action - Either :request or :verify. Required.
  • label - Optional override for the submit button label.
  • disable_text - Text shown while the request is in flight.
  • overrides - A list of override modules.
  • gettext_fn - Optional text translation function.