You are here

function _ga_login_explanation_form in Google Authenticator login 7

Form to create a new code - Introduction.

1 call to _ga_login_explanation_form()
ga_login_create_form in ./ga_login.pages.inc
Form to create a new code.

File

./ga_login.pages.inc, line 36
ga_login pages.

Code

function _ga_login_explanation_form($form, &$form_state, $account) {
  $form['two_step_verification'] = array(
    '#type' => 'container',
    '#title' => t('Two step verification'),
    '#prefix' => '<h2>' . t('Two step verification') . '</h2>',
  );
  $form['two_step_verification']['security'] = array(
    '#markup' => '<h3>' . t('2-step verification adds an extra layer of security to your account') . '</h3>' . t("In addition to your username and password, you'll enter a code that Google will send you via their !mobile_app.\n      If you do not have a smartphone, you can use the !desktop_client (should work on all operating systems) or a !phone_client.", array(
      '!mobile_app' => l(t('mobile app'), 'http://support.google.com/accounts/bin/answer.py?hl=en&answer=1066447', array(
        'attributes' => array(
          'target' => '_blank',
        ),
      )),
      '!desktop_client' => l(t('desktop client'), 'http://blog.jcuff.net/2011/09/beautiful-two-factor-desktop-client.html', array(
        'attributes' => array(
          'target' => '_blank',
        ),
      )),
      '!phone_client' => l(t('windows/palm os/java phone client'), 'http://code.google.com/p/gauth4win/', array(
        'attributes' => array(
          'target' => '_blank',
        ),
      )),
    )),
  );
  $howitworks1 = array(
    '#type' => 'item',
    '#title' => t('Enter your password'),
    '#markup' => t("Whenever you sign in you'll enter your username and password as usual."),
  );
  $howitworks2 = array(
    '#type' => 'item',
    '#title' => t('Enter a code from your phone'),
    '#markup' => t("Then, you'll be asked for a code that will be sent to you via your mobile app."),
  );
  $suffix = t('To get this code you have to add the data you will see after completing this form, using you mobile app.');
  if (module_exists('mobile_codes')) {
    $suffix = t('To get this code you have to scan the bar code or manually add the data you will see after completing this form, using your mobile app.');
  }
  $form['two_step_verification']['how_it_works'] = array(
    '#theme' => 'item_list',
    '#type' => 'ol',
    '#title' => t('How it works'),
    '#items' => array(
      drupal_render($howitworks1),
      drupal_render($howitworks2),
    ),
    '#suffix' => $suffix,
  );
  $types = variable_get('ga_login_generation_types', 'BOTH');
  $hotptotp1 = array(
    '#type' => 'item',
    '#title' => t('Time-based code'),
    '#markup' => t('A time-based code will refresh (generate a new code) every time a certain amount of time has passed. It is considered to be more secure than a counter-based code.'),
  );
  $hotptotp2 = array(
    '#type' => 'item',
    '#title' => t('Counter-based code'),
    '#markup' => t('A counter-based code will only refresh if you do so manually in the mobile app.'),
  );
  $form['hotptotp'] = array(
    '#theme' => 'item_list',
    '#title' => format_plural($types == 'BOTH' ? 2 : 1, 'Supported code', 'Supported codes'),
    '#items' => array(),
  );
  switch ($types) {
    case 'TOTP':
      $form['hotptotp']['#items'] = array(
        drupal_render($hotptotp1),
      );
      break;
    case 'HOTP':
      $form['hotptotp']['#items'] = array(
        drupal_render($hotptotp2),
      );
      break;
    default:
      $form['hotptotp']['#items'] = array(
        drupal_render($hotptotp1),
        drupal_render($hotptotp2),
      );
      break;
  }

  // Keep track of uid, so we can skip a step if needed.
  $form['uid'] = array(
    '#type' => 'value',
    '#value' => $account->uid,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Get started'),
  );
  return $form;
}