MoAuthSupport.php in Google Authenticator / 2 Factor Authentication - 2FA 8
Same filename and directory in other branches
Contains support form for miniOrange 2FA Login Module.
Namespace
Drupal\miniorange_2fa\FormFile
src/Form/MoAuthSupport.phpView source
<?php
/**
* @file
* Contains support form for miniOrange 2FA Login Module.
*/
namespace Drupal\miniorange_2fa\Form;
use Drupal\Core\Form\FormBase;
use Drupal\miniorange_2fa\MoAuthUtilities;
use Drupal\miniorange_2fa\MiniorangeCustomerProfile;
/**
* Showing Support form info.
*/
class MoAuthSupport extends FormBase {
public function getFormId() {
return 'miniorange_2fa_support';
}
public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $form_state) {
$form['markup_library'] = array(
'#attached' => array(
'library' => array(
"miniorange_2fa/miniorange_2fa.license",
),
),
);
$form['markup_1'] = array(
'#markup' => '<div class="mo_saml_table_layout_1"><div class="mo_saml_table_layout mo_saml_container">
<h3>New 2FA method request</h3><div>Need new 2FA method? Just send us a requirement so we can help you.<br /><br /></div>',
);
$email = '';
$phone = '';
if (MoAuthUtilities::isCustomerRegistered()) {
$customer = new MiniorangeCustomerProfile();
$email = $customer
->getRegisteredEmail();
$phone = $customer
->getRegisteredPhone();
}
$form['mo_auth_email_address'] = array(
'#type' => 'textfield',
'#title' => t('Email Address'),
'#default_value' => $email,
'#attributes' => array(
'placeholder' => 'Enter your email',
'class' => array(
'mo_auth_new_2fa',
),
),
'#required' => TRUE,
);
$form['mo_auth_phone_number'] = array(
'#type' => 'textfield',
'#title' => t('Phone number'),
'#default_value' => $phone,
'#id' => 'query_phone',
'#description' => 'Enter number with country code Eg. +00xxxxxxxxxx',
'#attributes' => array(
'class' => array(
'query_phone',
'mo_auth_new_2fa',
),
'placeholder' => 'Enter number with country code Eg. +00xxxxxxxxxx',
),
);
$form['mo_auth_support_query'] = array(
'#type' => 'textarea',
'#id' => "mo_auth_new_2fa_text_area",
'#title' => t('Description'),
'#cols' => 5,
'#rows' => 5,
'#attributes' => array(
'placeholder' => 'Describe your requirement here!',
'class' => array(
'mo_auth_new_2fa',
),
),
'#required' => TRUE,
'#suffix' => '<br>',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
$form['markup_support_1'] = array(
'#markup' => '<br><br><br><br></div><div class="mo_saml_table_layout_support_1 mo_saml_container" id="ma_saml_support_query">
<h3><b>Know more about module:</b></h3><div>Need any help? We can help you with configuring miniOrange 2FA module on your site. Just send us a query and we will get back to you soon.<br /></div><br>',
);
$form['markup_support_2'] = array(
'#markup' => '<div>Click <a target="_blank" href="https://plugins.miniorange.com/drupal-two-factor-authentication-2fa">here</a> to know more about Drupal 8 2FA module.<br>
Click <a target="_blank" href="https://plugins.miniorange.com/drupal-2-factor-authentication-google-authentication">here</a> to see setup guide for Drupal 8 2FA module.<br><br>
Click <a target="_blank" href="https://plugins.miniorange.com/drupal">here</a> to see all other security related products which we provide for drupal.<br>
</div><br><br>',
);
MoAuthUtilities::faq($form, $form_state);
$form['miniorange_markup_end'] = array(
'#markup' => '</div></div>',
);
return $form;
}
public function submitForm(array &$form, \Drupal\Core\Form\FormStateInterface $form_state) {
$email = $form['mo_auth_email_address']['#value'];
$phone = $form['mo_auth_phone_number']['#value'];
$query = $form['mo_auth_support_query']['#value'];
MoAuthUtilities::send_support_query($email, $phone, $query);
}
}
Classes
Name | Description |
---|---|
MoAuthSupport | Showing Support form info. |