You are here

function MoAuthSetupTwoFactor::mo_auth_create_auth_type in Google Authenticator / 2 Factor Authentication - 2FA 8

Same name and namespace in other branches
  1. 8.2 src/Form/MoAuthSetupTwoFactor.php \Drupal\miniorange_2fa\Form\MoAuthSetupTwoFactor::mo_auth_create_auth_type()
1 call to MoAuthSetupTwoFactor::mo_auth_create_auth_type()
MoAuthSetupTwoFactor::buildForm in src/Form/MoAuthSetupTwoFactor.php
Form constructor.

File

src/Form/MoAuthSetupTwoFactor.php, line 176
Contains Setup Two-Factor page for miniOrange 2FA Login Module.

Class

MoAuthSetupTwoFactor
Showing Setup Two-Factor page.

Namespace

Drupal\miniorange_2fa\Form

Code

function mo_auth_create_auth_type($authType, $configuredMethods, $active_method, $reconfigure_allowed, $base_url) {
  $label_title = 'Supported in ' . implode(', ', $authType['supported-for']);
  $supported_for_icon_class = '';
  if (in_array('Landline', $authType['supported-for'])) {
    $supported_for_icon_class = 'mo2f-landline';
  }
  elseif (in_array('Feature Phones', $authType['supported-for'])) {
    $supported_for_icon_class = 'mo2f-smartphone-feature-phone';
  }
  elseif (in_array('Laptops', $authType['supported-for'])) {
    $supported_for_icon_class = 'mo2f-laptop';
  }
  elseif (in_array('Smartphones', $authType['supported-for'])) {
    $supported_for_icon_class = 'mo2f-smartphone';
  }
  elseif (in_array('Laptops Phones', $authType['supported-for'])) {
    $supported_for_icon_class = 'mo2f-smartphone-feature-phone-laptop';
  }
  $config_type_class = 'mo2f-unconfigured-method';
  if ($authType['code'] == $active_method) {
    $config_type_class = 'mo2f-active-method';
  }
  elseif (in_array($authType['code'], $configuredMethods)) {
    $config_type_class = 'mo2f-configured-method';
  }
  $authTypeID = $authType['id'];
  $Configure = "{$base_url}/admin/config/people/miniorange_2fa/setup/user/configure/{$authTypeID}";
  $Test = "{$base_url}/admin/config/people/miniorange_2fa/setup/user/test/{$authTypeID}";
  $Re_Configure = "{$base_url}/admin/config/people/miniorange_2fa/setup/user/configure/{$authTypeID}";
  if (!MoAuthUtilities::isCustomerRegistered()) {
    $Configure = "{$base_url}/admin/config/people/miniorange_2fa/customer_setup";
    $Test = "{$base_url}/admin/config/people/miniorange_2fa/customer_setup";
    $Re_Configure = "{$base_url}/admin/config/people/miniorange_2fa/customer_setup";
  }
  $configured = 'false';
  $classes = $supported_for_icon_class . ' ' . $config_type_class;
  $test = '<a href="' . $Configure . '">Configure</a>';
  if (!empty($configuredMethods) && in_array($authType['code'], $configuredMethods)) {
    $test = '<a href="' . $Test . '">Test</a>';
    if ($reconfigure_allowed === TRUE) {
      $test .= ' | <a href="' . $Re_Configure . '">Re-configure</a>';
    }
    $configured = 'true';
  }
  $html = '<span>
                    <span class="mo2f-method" data-id="' . $authType['id'] . '" data-configured="' . $configured . '">' . $authType['name'] . '</span>
                    <p>' . $authType['description'] . '</p>
                    <div class="' . $classes . '" title="' . $label_title . '">' . $test . '</div>
                    <div><br><hr><hr><br></div>
                </span>';
  return $html;
}