You are here

function authenticate_user::mo_auth_build_otp_over_email_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_otp_over_email_form()
1 call to authenticate_user::mo_auth_build_otp_over_email_form()
authenticate_user::mo_auth_build_form_content in src/Form/authenticate_user.php

File

src/Form/authenticate_user.php, line 649
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_otp_over_email_form($form, $success_message = TRUE) {
  if ($success_message === TRUE) {
    $message = t('Please enter the OTP sent to your registered email.');
  }
  else {
    $message = t('The OTP you have entered is incorrect. Please enter the valid OTP.');
  }
  $message_div_class = $success_message === TRUE ? 'mo2f-message-status' : 'mo2f-message-error';
  $form['header']['#markup'] .= t('<div class="mo2f-message ' . $message_div_class . '">' . $message . '</div>');
  $form['header']['#markup'] .= t('<div class="mo2f-info">Enter the passcode:</div>');
  $form['token'] = array(
    '#type' => 'textfield',
    '#title' => t('Please enter the OTP you received:'),
    '#attributes' => array(
      'autofocus' => TRUE,
      'placeholder' => t('Enter OTP'),
    ),
    '#required' => TRUE,
    '#maxlength' => 8,
  );
  $form['mo_message'] = $message;
  return $form;
}