function handle_page_one_submit in Google Authenticator / 2 Factor Authentication - 2FA 7
1 call to handle_page_one_submit()
File
- ./
mo_auth_inline_registration.inc, line 552
Code
function handle_page_one_submit($form, &$form_state) {
$email = variable_get('mo_auth_make_email_editable', false) == false ? user_load($form_state['uid'])->mail : $form_state['input']['mo_auth_user_email'];
$users = entity_load('user');
$email_used = FALSE;
foreach ($users as $u) {
if (!empty($u->miniorange_registered_email)) {
$registered_email = $u->miniorange_registered_email[LANGUAGE_NONE][0]['value'];
if (strcasecmp(trim($registered_email), trim($email)) == 0) {
$email_used = TRUE;
break;
}
}
}
if ($email_used) {
// Send Status as this to show error message
$form = mo_auth_inline_registration_page_one('USER_FOUND_UNDER_DIFFERENT_CUSTOMER', $email, FALSE);
$form_state['complete form']['mo_auth_user_email']['#prefix'] = $form['mo_auth_user_email']['#prefix'];
form_set_error('user_registration', 'This email is already in use. Please try another email.');
$form_state["rebuild"] = TRUE;
// Added
return $form;
}
$customer = new MiniorangeCustomerProfile();
$miniorange_user = new MiniorangeUser($customer
->getCustomerID(), $email, NULL, NULL, NULL);
$user_api_handler = new UsersAPIHandler($customer
->getCustomerID(), $customer
->getAPIKey());
$response = $user_api_handler
->search($miniorange_user);
if ($response->status == 'USER_FOUND' || $response->status == 'USER_NOT_FOUND') {
$challenge_response = send_otp_email_to_user($email);
if ($challenge_response->status == 'SUCCESS') {
// if (true) {
/*
* We set this to determine which elements to display when the page reloads.
* Values below in the $form_state['storage'] array are saved to carry
* forward to subsequent pages in the form.
*/
$form_state['storage']['page_two'] = TRUE;
$form_state['storage']['page_one_values'] = $form_state['values'];
$form_state['storage']['page_one_values']['user_search_response'] = $response;
$form_state['storage']['page_one_values']['user_challenge_response'] = $challenge_response;
$form_state["rebuild"] = TRUE;
// Added
}
else {
drupal_set_message('An error occurred while registering. Please contact your administrator.', 'error');
}
}
elseif ($response->status == 'USER_FOUND_UNDER_DIFFERENT_CUSTOMER') {
$error_form = mo_auth_inline_registration_page_one($response->status, $email, FALSE);
$form_state['complete form']['mo_auth_user_email']['#prefix'] = $error_form['mo_auth_user_email']['#prefix'];
form_set_error('user_registration', 'This email is already in use. Please try another email.');
$form_state["rebuild"] = TRUE;
// Added
return;
}
else {
form_set_error('user_registration', $response->message);
drupal_goto("user");
}
}