You are here

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

Same name and namespace in other branches
  1. 8.2 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 192
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) {
  $form['main-header']['#markup'] = t('<style>#messages div.messages{visibility:hidden;}</style>');
  $form['header']['#markup'] = t('<div class="mo2f-modal">
              <div class="mo2f-modal-content">
                <div class="mo2f-modal-container mo2f-modal-header">Verify your identity</div>
                <div class="mo2f-modal-container">');
  $form = $this
    ->mo_auth_build_form_content($form, $base_url, $authType, $challenge_response, $success_form);
  $authTypeToHideButton = $authType['code'];
  $hide_button = '';
  if ($authTypeToHideButton == 'OUT OF BAND EMAIL' || $authTypeToHideButton == 'MOBILE AUTHENTICATION' || $authTypeToHideButton == 'PUSH NOTIFICATIONS') {
    $hide_button = 'hidebutton';
  }
  $form['loader']['#markup'] = '</div><div class="mo2f-modal-container mo2f-modal-footer">';
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Verify'),
    '#attributes' => array(
      'class' => array(
        $hide_button,
      ),
    ),
    '#submit' => array(
      '::mo_auth_authenticate_user_submit',
    ),
  );
  $query_param = \Drupal::service('path.current')
    ->getPath();
  $url_parts = explode('/', $query_param);
  end($url_parts);
  $user_id = prev($url_parts);
  if ($authType['code'] != 'KBA' && !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',
        ),
      ),
      '#value' => t('forgot phone'),
      '#submit' => array(
        '::mo_auth_forgot_phone',
      ),
      '#limit_validation_errors' => array(),
    );
  }
  $form['actions']['cancel'] = array(
    '#markup' => '&nbsp;<a href="' . $base_url . '"> Cancel</a>',
    '#suffix' => '</div></div></div>',
  );
  return $form;
}