You are here

function miniorange_2fa_inline_registration::mo_auth_inline_registration_page_five in Google Authenticator / 2 Factor Authentication - 2FA 8.2

Same name and namespace in other branches
  1. 8 src/Form/miniorange_2fa_inline_registration.php \Drupal\miniorange_2fa\form\miniorange_2fa_inline_registration::mo_auth_inline_registration_page_five()
1 call to miniorange_2fa_inline_registration::mo_auth_inline_registration_page_five()
miniorange_2fa_inline_registration::buildForm in src/Form/miniorange_2fa_inline_registration.php
Form constructor.

File

src/Form/miniorange_2fa_inline_registration.php, line 480
Page 1: Select Email address. Page 2: Verify OTP. Page 3: Select Auth Method. Page 4: Configure Auth Method. Page 5: Configure KBA.

Class

miniorange_2fa_inline_registration
@file Page 1: Select Email address. Page 2: Verify OTP. Page 3: Select Auth Method. Page 4: Configure Auth Method. Page 5: Configure KBA.

Namespace

Drupal\miniorange_2fa\form

Code

function mo_auth_inline_registration_page_five($form, $form_state) {
  $this
    ->handle2FAReset($form, $form_state);
  $enable_kba = \Drupal::config('miniorange_2fa.settings')
    ->get('mo_auth_2fa_kba_questions') == 'Not_Allowed' ? false : true;
  if (!$enable_kba) {
    $this
      ->handle_page_five_submit($form, $form_state);
  }
  $prefixQuestion1 = '<div class="mo2f-modal">
            <div class="mo2f-modal-content">
        <div class="mo2f-modal-container mo2f-modal-header">' . t('Configure Backup method (Step 5/5)') . '</div>
      <div class="mo2f-modal-container">
        <div class="mo2f-info">' . t('Please choose your backup security questions:') . '</div>
          <div>
            <div class="mo2f-kba-header mo2f-kba-row">
              <div class="mo2f-kba-srno">Sr. No.</div>
              <div class="mo2f-kba-question">' . t('Questions') . '</div>
              <div class="mo2f-kba-answer">' . t('Answers') . '</div>
            </div>
            <div class="mo2f-kba-row">
              <div class="mo2f-kba-srno">1.</div>
              <div class="mo2f-kba-question">';
  $suffixQuestion1 = '</div>';
  $prefixAnswer1 = '<div class="mo2f-kba-answer">';
  $suffixAnswer1 = '</div></div>';
  $prefixQuestion2 = '<div class="mo2f-kba-row">
            <div class="mo2f-kba-srno">2.</div>
            <div class="mo2f-kba-question">';
  $suffixQuestion2 = '</div>';
  $prefixAnswer2 = '<div class="mo2f-kba-answer">';
  $suffixAnswer2 = '</div></div>';
  $prefixQuestion3 = '<div class="mo2f-kba-row">
            <div class="mo2f-kba-srno">3.</div>
            <div class="mo2f-kba-question">';
  $suffixQuestion3 = '</div>';
  $prefixAnswer3 = '<div class="mo2f-kba-answer">';
  $suffixAnswer3 = '</div></div></div></div><div class="mo2f-modal-container mo2f-modal-footer">';
  $options_one = MoAuthUtilities::mo_get_kba_questions('ONE');
  $options_two = MoAuthUtilities::mo_get_kba_questions('TWO');
  $form['mo_auth_question1'] = array(
    '#type' => 'select',
    '#options' => $options_one,
    '#prefix' => $prefixQuestion1,
    '#suffix' => $suffixQuestion1,
    '#attributes' => array(
      'style' => 'width:85%;height:34px;padding-top:1px !important;',
    ),
    '#required' => TRUE,
  );
  $form['mo_auth_answer1'] = array(
    '#type' => 'textfield',
    '#prefix' => $prefixAnswer1,
    '#suffix' => $suffixAnswer1,
    '#size' => '20',
    '#attributes' => array(
      'placeholder' => t('Enter your answer'),
      'style' => 'width:85%;height:34px;',
    ),
    '#required' => TRUE,
  );
  $form['mo_auth_question2'] = array(
    '#type' => 'select',
    '#options' => $options_two,
    '#prefix' => $prefixQuestion2,
    '#suffix' => $suffixQuestion2,
    '#attributes' => array(
      'style' => 'width:85%;height:34px;padding-top:1px !important;',
    ),
    '#required' => TRUE,
  );
  $form['mo_auth_answer2'] = array(
    '#type' => 'textfield',
    '#prefix' => $prefixAnswer2,
    '#suffix' => $suffixAnswer2,
    '#attributes' => array(
      'placeholder' => t('Enter your answer'),
      'style' => 'width:85%;height:34px;',
    ),
    '#required' => TRUE,
  );
  $form['mo_auth_question3'] = array(
    '#type' => 'textfield',
    '#prefix' => $prefixQuestion3,
    '#suffix' => $suffixQuestion3,
    '#attributes' => array(
      'placeholder' => t('Enter your custom question here'),
      'style' => 'width:85%;height:34px;padding-top:1px !important;',
    ),
    '#required' => TRUE,
  );
  $form['mo_auth_answer3'] = array(
    '#type' => 'textfield',
    '#prefix' => $prefixAnswer3,
    '#suffix' => $suffixAnswer3,
    '#attributes' => array(
      'placeholder' => t('Enter your answer'),
      'style' => 'width:85%;height:34px;',
    ),
    '#required' => TRUE,
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['register'] = array(
    '#type' => 'submit',
    '#value' => t('Register'),
    '#submit' => array(
      '::handle_page_five_submit',
    ),
    '#attributes' => array(
      'class' => array(
        'mo2f_button',
      ),
    ),
  );
  $form['actions']['cancel'] = array(
    '#type' => 'submit',
    '#value' => t('Cancel'),
    '#limit_validation_errors' => array(),
    '#submit' => array(
      '::handle_page_cancel',
    ),
    '#attributes' => array(
      'class' => array(
        'mo2f_button',
      ),
    ),
  );
  return $form;
}