You are here

public function MiniorangeSamlCustomerSetup::submitForm in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 8

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

src/Form/MiniorangeSamlCustomerSetup.php, line 252
Contains \Drupal\miniorange_saml\Form\MiniorangeSamlCustomerSetup.

Class

MiniorangeSamlCustomerSetup

Namespace

Drupal\miniorange_saml\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $form_values = $form_state
    ->getValues();
  $tab = isset($_GET['tab']) ? $_GET['tab'] : 'register';
  $phone = '';
  if ($tab == 'register') {
    $username = trim($form_values['miniorange_saml_customer_register_username']);
    $phone = trim($form_values['miniorange_saml_customer_register_phone']);
    $password = trim($form_values['miniorange_saml_customer_register_password']);
  }
  else {
    $username = trim($form_values['miniorange_saml_customer_login_username']);
    $password = trim($form_values['miniorange_saml_customer_login_password']);
  }
  if (empty($username) || empty($password)) {
    \Drupal::messenger()
      ->addMessage(t('The <b><u>Email Address</u></b> and <b><u>Password</u></b> fields are mandatory.'), 'error');
    return;
  }
  if ($tab == 'register') {
    Utilities::customer_setup_submit($username, $phone, $password);
  }
  else {
    Utilities::customer_setup_submit($username, $phone, $password, true);
  }
}