<h1>Two-factor authentication</h1>
<p>
  Two-factor authentication adds another layer of security to your account by checking that you have access either to your
  phone or to your email account before signing you in. This prevents anyone who doesn't have access to one of those getting
  into your account.
</p>

<p>
  Two-factor authentication is currently
  <span class="badge is-tag <%= current_user.enabled_2fa? ? 'is-green' : 'is-red' %>">
    <strong><%= current_user.enabled_2fa ? 'on' : 'off' %></strong>
  </span>
  for your account.
  <% if current_user.enabled_2fa && current_user.two_factor_method == 'app' %>
    You'll get codes to sign in from an app on your phone.
  <% elsif current_user.enabled_2fa && current_user.two_factor_method == 'email' %>
    You'll get a link to sign in emailed to you.
  <% end %>
</p>

<% if current_user.enabled_2fa %>
  <p>
    <% if current_user.two_factor_method == 'app' %>
      <%= link_to 'Turn off', two_factor_disable_code_path, class: 'button is-outlined' %>
    <% elsif current_user.two_factor_method == 'email' %>
      <%= link_to 'Turn off', two_factor_send_disable_email_path, method: :post, class: 'button is-outlined' %>
    <% end %>
  </p>
<% else %>
  <div>
    <h3>Enable two-factor authentication</h3>
    <%= form_tag two_factor_enable_path do %>
      <div class="form-group">
        <%= select_tag :method, options_for_select([['Get codes from an app on your phone', 'app'],
                                                    ['Get a sign-in link emailed to you', 'email']]),
                       { class: 'form-element' } %>
      </div>

      <%= submit_tag 'Enable', class: 'button is-filled' %>
    <% end %>
  </div>
<% end %>