function miniorange_2fa_inline_registration::mo_auth_get_qrcode_authentication_form in Google Authenticator / 2 Factor Authentication - 2FA 8.2
Same name and namespace in other branches
- 8 src/Form/miniorange_2fa_inline_registration.php \Drupal\miniorange_2fa\form\miniorange_2fa_inline_registration::mo_auth_get_qrcode_authentication_form()
1 call to miniorange_2fa_inline_registration::mo_auth_get_qrcode_authentication_form()
File
- src/
Form/ miniorange_2fa_inline_registration.php, line 996 - Page 1: Select Email address. Page 2: Verify OTP. Page 3: Select Auth Method. Page 4: Configure Auth Method. Page 5: Configure KBA.
Class
- miniorange_2fa_inline_registration
- @file Page 1: Select Email address. Page 2: Verify OTP. Page 3: Select Auth Method. Page 4: Configure Auth Method. Page 5: Configure KBA.
Namespace
Drupal\miniorange_2fa\formCode
function mo_auth_get_qrcode_authentication_form(array $form, FormStateInterface $form_state, $success_form) {
global $base_url;
$storage = $form_state
->getStorage();
$email = $storage['page_one_values']['mo_auth_user_email'];
$method = $storage['page_three_values']['mo_auth_method'];
$configureMessage = t('Configure QR Code Authentication');
if ($method == AuthenticationType::$SOFT_TOKEN['code']) {
$configureMessage = t('Configure Soft Token');
}
elseif ($method == AuthenticationType::$PUSH_NOTIFICATIONS['code']) {
$configureMessage = t('Configure Push Notification');
}
$stepMessage = $this
->is2FAResetRequest($form_state) ? '' : t('(Step 4/5)');
$customer = new MiniorangeCustomerProfile();
$auth_api_handler = new AuthenticationAPIHandler($customer
->getCustomerID(), $customer
->getAPIKey());
$miniorange_user = new MiniorangeUser($customer
->getCustomerID(), $email, NULL, NULL, NULL);
$response = $auth_api_handler
->register($miniorange_user, AuthenticationType::$QR_CODE['code'], NULL, NULL, NULL);
if ($response->status == 'IN_PROGRESS') {
$page = [
'page_four_values' => [
'qrcode_response' => $response,
],
'page_three_values' => $storage['page_three_values'],
'page_two_values' => $storage['page_two_values'],
'page_one_values' => $storage['page_one_values'],
];
$form_state
->setStorage($page);
$qrCode = $response->qrCode;
$image = new FormattableMarkup('<img class="mo2f_image" src="data:image/jpg;base64, ' . $qrCode . '"/>', [
':src' => $qrCode,
]);
$iPhoneAppLink = file_create_url($base_url . '/' . drupal_get_path('module', 'miniorange_2fa') . '/includes/images/iphone-google-authenticator-app-link.png');
$androidAppLink = file_create_url($base_url . '/' . drupal_get_path('module', 'miniorange_2fa') . '/includes/images/android-google-authenticator-app-link.png');
$form['actions_31'] = array(
'#markup' => '<div class="mo2f-modal">
<div class="mo2f-modal-content">
<div class="mo2f-modal-container mo2f-modal-header">' . $configureMessage . ' ' . $stepMessage . ' </div>
<div class="mo2f-modal-container">',
);
$form['actions_32'] = array(
'#markup' => '<div><div class="mo2f-info"><b class="mo2f_bold">' . t('Step 1:') . '</b> ' . t('Download and install the miniOrange Authenticator app') . '</div>
<div class="mo2f-text-center" style="display:inline-block;width:60%;text-align:center">
<a target="_blank" href="https://itunes.apple.com/us/app/miniorange-authenticator/id796303566?ls=1"><img class="mo2f_image" src="' . $iPhoneAppLink . '"></a>
</div>
<div class="mo2f-text-center" style="display:inline-block">
<a target="_blank" href="https://play.google.com/store/apps/details?id=com.miniorange.authbeta"><img class="mo2f_image" src="' . $androidAppLink . '"></a>
</div>
</div>',
);
$form['actions_33'] = array(
'#markup' => '<div><div class="mo2f-info"><b class="mo2f_bold">Step 2:</b> Scan the QR Code from miniOrange Authenticator app</div>
<div class="mo2f-info"><b class="mo2f_bold">Note:</b> Once you scan the QR code, page will get automatically submitted (Dont refresh the page).</div>
<div class="mo2f-info mo2f-text-center">',
);
$form['actions_qrcode_miniOrange'] = array(
'#markup' => $image,
);
$form['actions_34'] = array(
'#markup' => '</div></div>',
);
$sufix = '</div><div class="mo2f-modal-container mo2f-modal-footer">';
$form['txId'] = array(
'#type' => 'hidden',
'#value' => $response->txId,
'#suffix' => $sufix,
);
$form['url'] = array(
'#type' => 'hidden',
'#value' => MoAuthConstants::getBaseUrl() . MoAuthConstants::$AUTH_REGISTRATION_STATUS_API,
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['verify'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#attributes' => array(
'class' => array(
'hidebutton',
'mo2f_button',
),
),
'#submit' => array(
'::handle_page_four_submit',
),
);
$form['actions']['cancel'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#submit' => array(
'::handle_page_cancel',
),
'#attributes' => array(
'class' => array(
'mo2f_button',
),
),
);
}
return $form;
}