function mo_auth_configure_otp_over_sms_and_email_submit in Google Authenticator / 2 Factor Authentication - 2FA 7
1 string reference to 'mo_auth_configure_otp_over_sms_and_email_submit'
File
- ./
configure_otp_over_sms_and_email.inc, line 72
Code
function mo_auth_configure_otp_over_sms_and_email_submit($form, &$form_state) {
$form_state['rebuild'] = TRUE;
$phone_number = $form['miniorange_phone']['#value'];
$phone_number = str_replace(' ', '', $phone_number);
if (empty($phone_number)) {
drupal_set_message(t('Please enter phone number to proceed.'), 'warning');
return;
}
global $base_url, $user;
$customer = new MiniorangeCustomerProfile();
$custID = $customer
->getCustomerID();
$api_key = $customer
->getAPIKey();
$user = user_load($user->uid);
$user_email = $user->miniorange_registered_email[LANGUAGE_NONE][0]['value'];
$currentMethod = "OTP_OVER_SMS_AND_EMAIL";
$customer_config = new MiniorangeCustomerSetup($user_email, $phone_number, NULL, NULL);
$params = array(
'phone' => $phone_number,
'email' => $user_email,
);
$response = $customer_config
->send_otp_token($params, $currentMethod, $custID, $api_key);
$send_otp_response = json_decode($response);
if ($send_otp_response->status == 'SUCCESS') {
// Store txID.
variable_set('mo_auth_tx_id', $send_otp_response->txId);
drupal_set_message(t('We have sent an OTP to @phone and @email. Please enter the OTP to verify your phone number.', array(
'@phone' => $phone_number,
'@email' => $user_email,
)));
}
elseif ($send_otp_response->status == 'CURL_ERROR') {
drupal_set_message(t('cURL is not enabled. Please enable cURL'), 'error');
}
else {
drupal_set_message(t($send_otp_response->message), 'error');
}
}