%div
  .login-box
    .login-heading
      %h3 Two-Factor Authentication
    .login-body
      - if @user.two_factor_otp_enabled?
        %h5 Authenticate via Two-Factor App
        = form_for(resource, as: resource_name, url: session_path(resource_name), method: :post) do |f|
          = f.hidden_field :remember_me, value: params[resource_name][:remember_me]
          = f.text_field :otp_attempt, class: 'form-control', placeholder: 'Two-Factor Authentication code', required: true, autofocus: true, autocomplete: 'off'
          %p.help-block.hint Enter the code from the two-factor app on your mobile device. If you've lost your device, you may enter one of your recovery codes.
          .prepend-top-20
            = f.submit "Verify code", class: "btn btn-save"

      - if @user.two_factor_u2f_enabled?

        %hr
        = render "u2f/authenticate"

%div
  .login-box
    .login-heading
      %h3 Two-Factor Authentication
    .login-body
      - if @user.two_factor_otp_enabled?
        %h5 Authenticate via Two-Factor App
        = form_for(resource, as: resource_name, url: session_path(resource_name), method: :post) do |f|
          - resource_params = params[resource_name].presence || params
          = f.hidden_field :remember_me, value: resource_params.fetch(:remember_me, 0)
          = f.text_field :otp_attempt, class: 'form-control', placeholder: 'Two-Factor Authentication code', required: true, autofocus: true, autocomplete: 'off'
          %p.help-block.hint Enter the code from the two-factor app on your mobile device. If you've lost your device, you may enter one of your recovery codes.
          .prepend-top-20
            = f.submit "Verify code", class: "btn btn-save"

      - if @user.two_factor_u2f_enabled?

        %hr
        = render "u2f/authenticate"

Fix 2FA-based login for LDAP users
Fix 2FA-based login for LDAP users

The OTP input form is shared by both LDAP and standard logins, but when
coming from an LDAP-based form, the form parameters aren't nested in a
Hash based on the `resource_name` value.

Now we check for a nested `remember_me` parameter and use that if it
exists, or fall back to the non-nested parameters if it doesn't.

Somewhat confusingly, the OTP input form _does_ nest parameters under
the `resource_name`, regardless of what type of login we're coming from,
so that allows everything else to work as normal.
