You are here

function tfa_basic_overview in TFA Basic plugins 7

TFA Basic account setup overview page.

1 string reference to 'tfa_basic_overview'
tfa_basic_menu in ./tfa_basic.module
Implements hook_menu().

File

./tfa_basic.pages.inc, line 6

Code

function tfa_basic_overview($form, &$form_state, $account) {
  $output['info'] = array(
    '#type' => 'markup',
    '#markup' => '<p>' . t('Two-factor authentication (TFA) provides additional security for your account. With TFA enabled, you log in to the site with a verification code in addition to your username and password.') . '</p>',
  );
  $form_state['storage']['account'] = $account;
  $user_tfa = tfa_basic_get_tfa_data($account);
  $enabled = isset($user_tfa['status']) && $user_tfa['status'] ? TRUE : FALSE;
  if (!empty($user_tfa)) {
    if ($enabled) {
      $status_text = t('Status: <strong>TFA enabled</strong>, set !time. <a href="!url">Disable TFA</a>', array(
        '!time' => format_date($user_tfa['saved']),
        '!url' => url('user/' . $account->uid . '/security/tfa/disable'),
      ));
    }
    else {
      $status_text = t('Status: <strong>TFA disabled</strong>, set !time.', array(
        '!time' => format_date($user_tfa['saved']),
      ));
    }
    $output['status'] = array(
      '#type' => 'markup',
      '#markup' => '<p>' . $status_text . '</p>',
    );
  }

  // Start with validate plugin setup.
  if (!$enabled) {
    $validate_plugin = variable_get('tfa_validate_plugin', '');
    $output['setup'] = _tfa_basic_plugin_setup_form_overview($validate_plugin, $account, $user_tfa);
  }
  else {

    // TOTP setup.
    $output['app'] = _tfa_basic_plugin_setup_form_overview('tfa_basic_totp', $account, $user_tfa);

    // SMS setup.
    $output['sms'] = _tfa_basic_plugin_setup_form_overview('tfa_basic_sms', $account, $user_tfa);

    // Trusted browsers.
    $output['trust'] = _tfa_basic_plugin_setup_form_overview('tfa_basic_trusted_browser', $account, $user_tfa);

    // Recovery codes.
    $output['recovery'] = _tfa_basic_plugin_setup_form_overview('tfa_basic_recovery_code', $account, $user_tfa);
  }
  return $output;
}