function MoAuthSetupTwoFactor::mo_auth_create_auth_type in Google Authenticator / 2 Factor Authentication - 2FA 8.2
Same name and namespace in other branches
- 8 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 218 - Contains Setup Two-Factor page for miniOrange 2FA Login Module.
Class
- MoAuthSetupTwoFactor
- Showing Setup Two-Factor page.
Namespace
Drupal\miniorange_2fa\FormCode
function mo_auth_create_auth_type($authType, $configuredMethods, $active_method, $reconfigure_allowed, $base_url) {
$utilities = new MoAuthUtilities();
$label_title = 'Supported in ' . implode(', ', $authType['supported-for']);
$supported_for_icon_class = '';
if (in_array(AuthenticationType::landline, $authType['supported-for'])) {
$supported_for_icon_class = 'mo2f-landline';
}
elseif (in_array(AuthenticationType::feature_phones, $authType['supported-for'])) {
$supported_for_icon_class = 'mo2f-smartphone-feature-phone';
}
elseif (in_array(AuthenticationType::laptops, $authType['supported-for'])) {
$supported_for_icon_class = 'mo2f-laptop';
}
elseif (in_array(AuthenticationType::smartphones, $authType['supported-for'])) {
$supported_for_icon_class = 'mo2f-smartphone';
}
elseif (in_array(AuthenticationType::laptops_phones, $authType['supported-for'])) {
$supported_for_icon_class = 'mo2f-smartphone-feature-phone-laptop';
}
elseif (in_array(AuthenticationType::hardware_token, $authType['supported-for'])) {
$supported_for_icon_class = 'mo2f-yubikey-hardware-token';
}
$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'];
try {
$Test = Url::fromRoute($authType['test-route'])
->toString();
} catch (RouteNotFoundException $e) {
}
try {
$Re_Configure = $Configure = Url::fromRoute($authType['configure-route'])
->toString();
} catch (RouteNotFoundException $e) {
}
// $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";
$configure_text = t('Configure');
$test_text = t('Test');
$re_configure_text = t('Re-configure');
/**
* Change all the links to Register/Login tab as user is not registered or logged in yet.
*/
if (!$utilities::isCustomerRegistered()) {
$Configure = $Re_Configure = $Test = Url::fromRoute('miniorange_2fa.customer_setup')
->toString();
}
/**
* Show Contact us link as these features are not implemented yet.
*/
if ($authType['id'] === AuthenticationType::$OTP_OVER_WHATSAPP['id']) {
$Configure = Url::fromRoute('miniorange_2fa.support')
->toString();
$configure_text = t('Request this method');
}
$configured = 'false';
$classes = $supported_for_icon_class . ' ' . $config_type_class;
$test = '<a href="' . $Configure . '">' . $configure_text . '</a>';
if (!empty($configuredMethods) && in_array($authType['code'], $configuredMethods)) {
$test = '<a href="' . $Test . '">' . $test_text . '</a>';
if ($reconfigure_allowed === TRUE) {
$test .= ' | <a href="' . $Re_Configure . '" style="color:red">' . $re_configure_text . '</a>';
}
$configured = 'true';
}
$html = '<span>
<span class="mo2f-method" data-id="' . $authType['id'] . '" data-configured = "' . $configured . '">' . $authType['name'] . '</span>
<p>' . t($authType['description']) . '</p>
<div class="' . $classes . '" title="' . $label_title . '">' . $test . '</div>
<div><br><hr><hr><br></div>
</span>';
return $html;
}