You are here

function authenticate_user::mo_auth_build_form in Google Authenticator / 2 Factor Authentication - 2FA 8.2

Same name and namespace in other branches
  1. 8 src/Form/authenticate_user.php \Drupal\miniorange_2fa\form\authenticate_user::mo_auth_build_form()
2 calls to authenticate_user::mo_auth_build_form()
authenticate_user::buildForm in src/Form/authenticate_user.php
Form constructor.
authenticate_user::mo_auth_forgot_phone in src/Form/authenticate_user.php

File

src/Form/authenticate_user.php, line 241
This is used to authenticate user during login.

Class

authenticate_user
@file This is used to authenticate user during login.

Namespace

Drupal\miniorange_2fa\form

Code

function mo_auth_build_form($form, $base_url, $authType, $challenge_response, $success_form, $activated_auth_methods) {
  $variables_and_values = array(
    'mo_auth_2fa_allow_reconfigure_2fa',
  );
  $mo_db_values = MoAuthUtilities::miniOrange_set_get_configurations($variables_and_values, 'GET');
  $form['main-header']['#markup'] = t('<style>#messages div.messages{visibility:hidden;}</style>');
  $form['header']['#markup'] = '<div class="mo2f-modal">
              <div class="mo2f-modal-content">
                <div class="mo2f-modal-container mo2f-modal-header">' . t('Verify your identity') . '</div>
                <div class="mo2f-modal-container">';
  $form = $this
    ->mo_auth_build_form_content($form, $base_url, $authType, $challenge_response, $activated_auth_methods, $success_form);
  if ($mo_db_values['mo_auth_2fa_allow_reconfigure_2fa'] == 'Allowed') {
    $form['mo_auth_change_2fa'] = array(
      '#type' => 'checkbox',
      '#title' => t('I want to change/reconfigure my 2FA method.'),
      '#description' => t('<strong>Note:</strong> If you want to change/reconfigure the 2FA method then please check this checkbox and complete the authentication.'),
    );
  }
  $authTypeToHideButton = $authType['code'];
  $hide_button = '';
  if ($authTypeToHideButton == AuthenticationType::$EMAIL_VERIFICATION['code'] || $authTypeToHideButton == AuthenticationType::$QR_CODE['code'] || $authTypeToHideButton == AuthenticationType::$PUSH_NOTIFICATIONS['code']) {
    $hide_button = 'hidebutton';
  }
  $form['loader']['#markup'] = '</div><div class="mo2f-modal-container mo2f-modal-footer">';
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['verify'] = array(
    '#type' => 'submit',
    '#value' => t('Verify'),
    '#attributes' => array(
      'class' => array(
        $hide_button,
        'mo2f_button',
      ),
    ),
    '#submit' => array(
      '::mo_auth_authenticate_user_submit',
    ),
  );
  $url_parts = MoAuthUtilities::mo_auth_get_url_parts();
  end($url_parts);
  $user_id = prev($url_parts);
  if ($authType['code'] != AuthenticationType::$KBA['code'] && !MoAuthUtilities::mo_auth_is_kba_configured($user_id) === FALSE) {
    $form['actions']['forgot'] = array(
      '#type' => 'submit',
      '#attributes' => array(
        'class' => array(
          'mo_auth_forgot_phone_btn_class',
          'mo2f_button',
        ),
      ),
      '#value' => t('forgot phone'),
      '#submit' => array(
        '::mo_auth_forgot_phone',
      ),
      '#limit_validation_errors' => array(),
    );
  }
  $form['actions']['cancel'] = array(
    '#type' => 'submit',
    '#value' => t('Cancel'),
    '#submit' => array(
      '::handle_page_cancel',
    ),
    '#attributes' => array(
      'class' => array(
        'mo2f_button',
      ),
    ),
    '#limit_validation_errors' => array(),
  );
  return $form;
}