class MoAuthSupport in Google Authenticator / 2 Factor Authentication - 2FA 8.2
Same name and namespace in other branches
- 8 src/Form/MoAuthSupport.php \Drupal\miniorange_2fa\Form\MoAuthSupport
Showing Support form info.
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\miniorange_2fa\Form\MoAuthSupport
Expanded class hierarchy of MoAuthSupport
1 string reference to 'MoAuthSupport'
File
- src/
Form/ MoAuthSupport.php, line 17 - Contains support form for miniOrange 2FA Login Module.
Namespace
Drupal\miniorange_2fa\FormView source
class MoAuthSupport extends FormBase {
public function getFormId() {
return 'miniorange_2fa_support';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form['markup_library'] = array(
'#attached' => array(
'library' => array(
"miniorange_2fa/miniorange_2fa.license",
"miniorange_2fa/miniorange_2fa.admin",
),
),
);
$email = '';
$phone = '';
$user = User::load(\Drupal::currentUser()
->id());
$user_id = $user
->id();
$phoneNumber = MoAuthUtilities::getUserPhoneNumber($user_id);
if (MoAuthUtilities::isCustomerRegistered()) {
$customer = new MiniorangeCustomerProfile();
$email = $customer
->getRegisteredEmail();
$phone = $phoneNumber;
}
$form['markup_1'] = array(
'#markup' => t('<div class="mo_2fa_table_layout_1"><div class="mo_2fa_table_layout mo_2fa_container">'),
);
$form['mo_auth_vertical_tabs'] = array(
'#type' => 'vertical_tabs',
'#default_tab' => 'edit-publication',
);
/**
* Support form
*/
$form['miniorange_support'] = array(
'#type' => 'details',
'#title' => t('Support'),
'#group' => 'mo_auth_vertical_tabs',
);
$form['miniorange_support']['markup_1'] = array(
'#markup' => t('<h3>Support</h3><hr><p class="mo_2fa_highlight_background_note">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.</p>'),
);
$form['miniorange_support']['mo_auth_support_email_address'] = array(
'#type' => 'email',
'#title' => t('Email') . '<span style="color: red">*</span>',
'#default_value' => $email,
'#attributes' => array(
'placeholder' => t('Enter your email'),
'style' => 'width:99%',
),
);
$form['miniorange_support']['mo_auth_support_phone_number'] = array(
'#type' => 'textfield',
'#title' => t('Phone'),
'#default_value' => $phone,
'#id' => 'query_phone',
'#description' => '<strong>' . t('Note:') . '</strong>' . t('Enter phone number with country code Eg. +00xxxxxxxxxx'),
'#attributes' => array(
'placeholder' => t('Enter phone number with country code Eg. +00xxxxxxxxxx'),
'style' => 'width:99%;',
'class' => array(
'query_phone',
),
),
);
$form['miniorange_support']['mo_auth_support_query'] = array(
'#type' => 'textarea',
'#id' => "mo_auth_new_2fa_text_area",
'#title' => t('Query') . ' <span style="color: red">*</span>',
'#attributes' => array(
'placeholder' => t('Describe your query here!'),
'style' => 'width:99%',
),
'#suffix' => '<br>',
);
$form['miniorange_support']['actions']['submit'] = array(
'#type' => 'submit',
'#button_type' => 'primary',
'#value' => t('Submit query'),
);
$form['miniorange_support']['markup_support_note'] = array(
'#markup' => '<div><br/><br/>' . t('If you want custom features in the module, just drop an email to') . ' <a href="mailto:info@xecurify.com">info@xecurify.com</a>' . t(' or ') . ' <a href="mailto:drupalsupport@xecurify.com">drupalsupport@xecurify.com</a></div><br><hr><br>',
);
/**
* Request demo form
*/
$form['miniorange_demo_request'] = array(
'#type' => 'details',
'#title' => t('Request demo'),
'#group' => 'mo_auth_vertical_tabs',
);
$form['miniorange_demo_request']['markup_demo_request'] = array(
'#markup' => '<h3>' . t('Request Demo of Premium features') . '</h3><hr><p class="mo_2fa_highlight_background_note">' . t('Want to know about how the licensed module works? Let us know and we will arrange a demo for you.') . '</p>',
);
$form['miniorange_demo_request']['mo_auth_demo_email_address'] = array(
'#type' => 'email',
'#title' => t('Email') . ' <span style="color: red">*</span>',
'#default_value' => $email,
'#attributes' => array(
'placeholder' => t('Enter your email'),
'style' => 'width:99%',
),
);
$form['miniorange_demo_request']['mo_auth_demo_plan'] = array(
'#type' => 'select',
'#title' => t('Plan'),
'#options' => array(
'Drupal 8 2FA Premium' => t('Drupal 8 2FA Premium'),
'Drupal 8 2FA Premium + Website Security Premium' => t('Drupal 8 2FA Premium + Website Security Premium'),
'Not Sure' => t('Not Sure, Need help for selecting plan.'),
),
'#attributes' => array(
'style' => 'width:99%;height:30px',
),
);
$form['miniorange_demo_request']['mo_auth_demo_description'] = array(
'#type' => 'textarea',
'#title' => t('Description') . ' <span style="color: red">*</span>',
'#attributes' => array(
'placeholder' => t('Describe your use case here!'),
'style' => 'width:99%',
),
'#suffix' => '<br>',
);
$form['miniorange_demo_request']['actions']['submit'] = array(
'#type' => 'submit',
'#button_type' => 'primary',
'#value' => t('Send Request'),
);
$form['miniorange_demo_request']['markup_demo_note'] = array(
'#markup' => '<div><br/><br/>' . t('If you are not sure with which plan you should go with, get in touch with us on') . ' <a href="mailto:drupalsupport@xecurify.com">drupalsupport@xecurify.com</a>' . t(' and we will assist you with the suitable plan.') . '</div><br><hr><br>',
);
/**
* New 2fa feature request form
*/
$form['miniorange_feature_request'] = array(
'#type' => 'details',
'#title' => t('New Feature Request'),
'#group' => 'mo_auth_vertical_tabs',
);
$form['miniorange_feature_request']['markup_1'] = array(
'#markup' => t('<h3>New 2FA feature/method request</h3><hr><p class="mo_2fa_highlight_background_note">Need new 2FA method? Just send us a requirement so we can help you.'),
);
$form['miniorange_feature_request']['mo_auth_feature_email_address'] = array(
'#type' => 'email',
'#title' => t('Email') . ' <span style="color: red">*</span>',
'#default_value' => $email,
'#attributes' => array(
'placeholder' => t('Enter your email'),
'style' => 'width:99%',
),
);
$form['miniorange_feature_request']['mo_auth_feature_phone_number'] = array(
'#type' => 'textfield',
'#title' => t('Phone'),
'#default_value' => $phone,
'#id' => 'query_phone',
'#description' => '<strong>' . t('Note:') . '</strong>' . t('Enter phone number with country code Eg. +00xxxxxxxxxx'),
'#attributes' => array(
'placeholder' => t('Enter phone number with country code Eg. +00xxxxxxxxxx'),
'style' => 'width:99%',
'class' => array(
'query_phone',
),
),
);
$form['miniorange_feature_request']['mo_auth_feature_query'] = array(
'#type' => 'textarea',
'#id' => "mo_auth_new_2fa_text_area",
'#title' => t('Description') . ' <span style="color: red">*</span>',
'#attributes' => array(
'placeholder' => t('Describe your requirement here!'),
'style' => 'width:99%',
),
'#suffix' => '<br>',
);
$form['miniorange_feature_request']['actions']['submit'] = array(
'#type' => 'submit',
'#button_type' => 'primary',
'#value' => t('Submit'),
);
$form['miniorange_feature_request']['markup_feature_request_note'] = array(
'#markup' => '<div><br/><br/>' . t('For any other queries, reach out to us using the support form or just drop an email to ') . '<a href="mailto:info@xecurify.com">info@xecurify.com</a>' . t(' or') . ' <a href="mailto:drupalsupport@xecurify.com">drupalsupport@xecurify.com</a></div><br><hr><br>',
);
$form['markup_support_1'] = array(
'#markup' => '<br><br><br><br></div><div class="mo_2fa_table_layout mo_auth_container_2" id="ma_saml_support_query">
<h3><b>' . t('Know more about module:') . '</b></h3><div>' . t('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>' . t('Click') . ' <a target="_blank" href="https://plugins.miniorange.com/drupal-two-factor-authentication-2fa">' . t('here') . '</a> ' . t('to know more about Drupal 8 2FA module.') . '<br>
' . t('Click') . ' <a target="_blank" href="https://plugins.miniorange.com/drupal-2fa-setup-guides">' . t('here') . '</a> ' . t('to see setup guides for various 2fa methods in this module.') . '<br><br>
' . t('Click') . ' <a target="_blank" href="https://plugins.miniorange.com/drupal">' . t('here') . '</a> ' . t('to see all other security related products which we provide for drupal.') . '<br><br><br>
<div class="mo2f_text_center"><b></b>
<a class="mo_saml_btn mo_saml_btn-primary-faq mo_saml_btn-large mo_auth_button_left" href="https://faq.miniorange.com/kb/drupal/two-factor-authentication-drupal/" target="_blank">FAQs</a>
<b></b><a class="mo_saml_btn mo_saml_btn-primary-faq mo_saml_btn-large mo_auth_button_right" href="https://forum.miniorange.com/" target="_blank">' . t('Ask questions on forum') . '</a></div></div><br>
</div><br><br>',
);
return $form;
}
public function validateForm(array &$form, FormStateInterface $form_state) {
$form_values = $form_state
->getValues();
if ($form_values['mo_auth_vertical_tabs__active_tab'] === 'edit-miniorange-support') {
if (!\Drupal::service('email.validator')
->isValid($form_values['mo_auth_support_email_address'])) {
$form_state
->setErrorByName('mo_auth_support_email_address', $this
->t('The email address is not valid.'));
}
if (empty($form_values['mo_auth_support_query'])) {
$form_state
->setErrorByName('mo_auth_support_query', $this
->t('The <b>Query</b> fields is mandatory'));
}
}
elseif ($form_values['mo_auth_vertical_tabs__active_tab'] === 'edit-miniorange-demo-request') {
if (!\Drupal::service('email.validator')
->isValid($form_values['mo_auth_demo_email_address'])) {
$form_state
->setErrorByName('mo_auth_demo_email_address', $this
->t('The email address is not valid.'));
}
if (empty($form_values['mo_auth_demo_description'])) {
$form_state
->setErrorByName('mo_auth_demo_description', $this
->t('The <b>Description</b> fields is mandatory'));
}
}
elseif ($form_values['mo_auth_vertical_tabs__active_tab'] === 'edit-miniorange-feature-request') {
if (!\Drupal::service('email.validator')
->isValid($form_values['mo_auth_feature_email_address'])) {
$form_state
->setErrorByName('mo_auth_feature_email_address', $this
->t('The email address is not valid.'));
}
if (empty($form_values['mo_auth_feature_query'])) {
$form_state
->setErrorByName('mo_auth_feature_query', $this
->t('The <b>Description</b> fields is mandatory'));
}
}
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_values = $form_state
->getValues();
$email = '';
$phone = '';
$query = '';
$query_type = '';
if ($form_values['mo_auth_vertical_tabs__active_tab'] === 'edit-miniorange-support') {
$email = $form_values['mo_auth_support_email_address'];
$phone = $form_values['mo_auth_support_phone_number'];
$query = $form_values['mo_auth_support_query'];
$query_type = 'Support';
}
elseif ($form_values['mo_auth_vertical_tabs__active_tab'] === 'edit-miniorange-demo-request') {
$email = $form_values['mo_auth_demo_email_address'];
$phone = $form_values['mo_auth_demo_plan'];
$query = $form_values['mo_auth_demo_description'];
$query_type = 'Demo Request';
}
elseif ($form_values['mo_auth_vertical_tabs__active_tab'] === 'edit-miniorange-feature-request') {
$email = $form_values['mo_auth_feature_email_address'];
$phone = $form_values['mo_auth_feature_phone_number'];
$query = $form_values['mo_auth_feature_query'];
$query_type = 'New Feature Request';
}
MoAuthUtilities::send_support_query($email, $phone, $query, $query_type);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Retrieves a configuration object. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
87 |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
MoAuthSupport:: |
public | function |
Form constructor. Overrides FormInterface:: |
|
MoAuthSupport:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
MoAuthSupport:: |
public | function |
Form submission handler. Overrides FormInterface:: |
|
MoAuthSupport:: |
public | function |
Form validation handler. Overrides FormBase:: |
|
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |