18F/identity-idp

View on GitHub
app/views/two_factor_authentication/otp_verification/show.html.erb

Summary

Maintainability
Test Coverage
<% self.title = t('titles.enter_2fa_code.one_time_code') %>

<% if @landline_alert %>
  <%= render AlertComponent.new(type: :warning, class: 'margin-bottom-2') do %>
    <%= @presenter.landline_warning %>
  <% end %>
<% end %>

<% if @presenter.otp_expiration.present? %>
  <%= render CountdownAlertComponent.new(
        show_at_remaining: IdentityConfig.store.otp_expiration_warning_seconds.seconds,
        alert_options: { class: 'margin-bottom-4' },
        countdown_options: { expiration: @presenter.otp_expiration },
      ) %>
<% end %>

<%= render PageHeadingComponent.new.with_content(@presenter.header) %>

<p>
  <%= @presenter.phone_number_message %>
</p>

<%= simple_form_for('') do |f| %>
  <% if @presenter.reauthn %>
    <%= render 'two_factor_authentication/totp_verification/reauthn' %>
  <% end %>
  <%= render OneTimeCodeInputComponent.new(
        form: f,
        autofocus: true,
        value: @presenter.code_value,
        optional_prefix: '#',
      ) %>
  <%= f.input(
        :remember_device,
        as: :boolean,
        label: t('forms.messages.remember_device'),
        input_html: {
          class: 'usa-checkbox__input--bordered',
          checked: @presenter.remember_device_box_checked?,
        },
      ) %>
  <%= f.submit t('forms.buttons.submit.default'), class: 'display-block margin-top-5 margin-bottom-2' %>
  <%= hidden_field_tag 'otp_make_default_number',
                       @presenter.otp_make_default_number %>
  <%= render ButtonComponent.new(
        url: otp_send_path(
          otp_delivery_selection_form: {
            otp_delivery_preference: @presenter.otp_delivery_preference,
            resend: true,
          },
        ),
        outline: true,
        icon: :loop,
        class: 'margin-bottom-neg-1',
      ).with_content(t('links.two_factor_authentication.send_another_code')) %>
<% end %>

<%= render 'two_factor_authentication/troubleshooting_options', presenter: @presenter %>
<% if MfaPolicy.new(current_user).two_factor_enabled? %>
  <%= render 'shared/cancel', link: @presenter.cancel_link %>
<% else %>
  <%= render 'shared/cancel_or_back_to_options' %>
<% end %>