public static function Utilities::customer_setup_submit in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 8
2 calls to Utilities::customer_setup_submit()
- MiniorangeSamlCustomerSetup::submitForm in src/
Form/ MiniorangeSamlCustomerSetup.php - Form submission handler.
- miniorange_saml_sp_registration::miniorange_saml_register_popup in src/
miniorange_saml_sp_registration.php
File
- src/
Utilities.php, line 668
Class
- Utilities
- This file is part of miniOrange SAML plugin.
Namespace
Drupal\miniorange_samlCode
public static function customer_setup_submit($username, $phone, $password, $login = false, $called_from_popup = false, $payment_plan = NULL) {
global $base_url;
$customer_config = new MiniorangeSAMLCustomer($username, $phone, $password, NULL);
$check_customer_response = json_decode($customer_config
->checkCustomer());
$db_config = \Drupal::configFactory()
->getEditable('miniorange_saml.settings');
if ($check_customer_response->status == 'TRANSACTION_LIMIT_EXCEEDED') {
if ($called_from_popup == true) {
miniorange_saml_sp_registration::register_data(true);
}
else {
\Drupal::messenger()
->addMessage(t('An error has been occured. Please Try after some time or <a href="mailto:' . MiniorangeSAMLConstants::SUPPORT_EMAIL . '"><i>contact us</i></a>.'), 'error');
return;
}
}
if ($check_customer_response->status == 'CUSTOMER_NOT_FOUND') {
if ($login == true && $called_from_popup == false) {
\Drupal::messenger()
->addMessage(t('The account with username <i>' . $username . '</i> does not exist.'), 'error');
return;
}
$db_config
->set('miniorange_saml_customer_admin_email', $username)
->save();
$db_config
->set('miniorange_saml_customer_admin_phone', $phone)
->save();
$db_config
->set('miniorange_saml_customer_admin_password', $password)
->save();
$send_otp_response = json_decode($customer_config
->sendOtp());
if ($send_otp_response->status == 'SUCCESS') {
$db_config
->set('miniorange_saml_tx_id', $send_otp_response->txId)
->save();
$db_config
->set('miniorange_saml_status', 'VALIDATE_OTP')
->save();
if ($called_from_popup == true) {
miniorange_saml_sp_registration::miniorange_otp(false, false, false);
}
else {
\Drupal::messenger()
->addMessage(t('Verify email address by entering the passcode sent to @username', [
'@username' => $username,
]));
}
}
else {
if ($called_from_popup == true) {
miniorange_saml_sp_registration::register_data(true);
}
else {
\Drupal::messenger()
->addMessage(t('An error has been occured. Please try after some time.'), 'error');
}
}
}
elseif ($check_customer_response->status == 'CURL_ERROR') {
if ($called_from_popup == true) {
miniorange_saml_sp_registration::register_data(true);
}
else {
\Drupal::messenger()
->addMessage(t('cURL is not enabled. Please enable cURL'), 'error');
return;
}
}
else {
$customer_keys_response = json_decode($customer_config
->getCustomerKeys());
if (json_last_error() == JSON_ERROR_NONE) {
$db_config
->set('miniorange_saml_customer_id', $customer_keys_response->id)
->save();
$db_config
->set('miniorange_saml_customer_admin_token', $customer_keys_response->token)
->save();
$db_config
->set('miniorange_saml_customer_admin_email', $username)
->save();
$db_config
->set('miniorange_saml_customer_admin_phone', $phone)
->save();
$db_config
->set('miniorange_saml_customer_api_key', $customer_keys_response->apiKey)
->save();
$db_config
->set('miniorange_saml_status', 'PLUGIN_CONFIGURATION')
->save();
if ($called_from_popup == true) {
$redirect_url = \Drupal::config('miniorange_saml.settings')
->get('redirect_plan_after_registration_' . $payment_plan);
$redirect_url = str_replace('none', $username, $redirect_url);
}
else {
$redirect_url = $base_url . MiniorangeSAMLConstants::LICENSING_TAB_URL;
}
$response = new RedirectResponse($redirect_url);
$response
->send();
}
else {
if ($called_from_popup == true) {
miniorange_saml_sp_registration::register_data(false, true);
}
else {
\Drupal::messenger()
->addMessage(t('Invalid credentials'), 'error');
return;
}
}
}
}