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

View Source

Function components for dealing with form input during TOTP authentication.

Component hierarchy

These function components are consumed by AshAuthentication.Phoenix.Components.Totp.SignInForm and AshAuthentication.Phoenix.Components.Totp.SetupForm.

Overrides

This component provides the following overrides:

  • :identity_input_label - Label for identity field.
  • :identity_input_placeholder - Placeholder for identity field.
  • :field_class - CSS class for div elements surrounding the fields.
  • :label_class - CSS class for label elements.
  • :input_class - CSS class for 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 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 TOTP code field.
  • :code_input_placeholder - Placeholder for TOTP code field.
  • :valid_code_class - CSS class applied to code field when validation passes.
  • :invalid_code_class - CSS class applied to code field when validation fails.

See AshAuthentication.Phoenix.Overrides for more information.

Summary

Functions

Generate a form field for the TOTP code.

Generate a list of errors for a field (if there are any).

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(:code_valid) => boolean() | nil,
  optional(:overrides) => [module()],
  optional(:gettext_fn) => {module(), atom()}
}) :: Phoenix.LiveView.Rendered.t() | no_return()

Generate a form field for the TOTP code.

Props

  • socket - Phoenix LiveView socket. Required.
  • strategy - The strategy configuration. Required.
  • form - An AshPhoenix.Form. Required.
  • code_valid - Boolean indicating if the code is currently valid (for setup forms).
  • overrides - A list of override modules.
  • gettext_fn - Optional text translation function.

error(assigns)

@spec error(%{
  :socket => Phoenix.LiveView.Socket.t(),
  :form => AshPhoenix.Form.t(),
  :field => atom(),
  optional(:field_label) => String.Chars.t(),
  optional(:errors) => [{atom(), String.t()}],
  optional(:gettext_fn) => {module(), atom()}
}) :: Phoenix.LiveView.Rendered.t() | no_return()

Generate a list of errors for a field (if there are any).

Props

  • socket - Phoenix LiveView socket. Required.
  • form - An AshPhoenix.Form. Required.
  • field - The field for which to retrieve the errors. 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. This is needed to be able to retrieve the correct CSS configuration. Required.
  • strategy - The configuration map as per AshAuthentication.authenticated_resources/1. Required.
  • form - An AshPhoenix.Form. Required.
  • input_type - Either :text or :email. If not set it will try and guess based on the name of the identity field.
  • 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 => :sign_in | :setup | :confirm_setup,
  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 strategy configuration. Required.
  • form - An AshPhoenix.Form. Required.
  • action - Either :sign_in, :setup, or :confirm_setup. Required.
  • label - The text to show in the submit label.
  • disable_text - Text to show when the button is disabled.
  • overrides - A list of override modules.
  • gettext_fn - Optional text translation function.