summaryrefslogtreecommitdiff
path: root/modules/openid/openid.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/openid/openid.module')
-rw-r--r--modules/openid/openid.module28
1 files changed, 27 insertions, 1 deletions
diff --git a/modules/openid/openid.module b/modules/openid/openid.module
index 92f477dd2..96a74415a 100644
--- a/modules/openid/openid.module
+++ b/modules/openid/openid.module
@@ -627,11 +627,37 @@ function openid_authentication($response) {
}
}
elseif (variable_get('user_register', 1)) {
- drupal_set_message(t('Complete the registration by filling out the form below. If you already have an account, you can <a href="@login">log in</a> now and add your OpenID under "My account".', array('@login' => url('user/login'))));
+ // Register new user.
// Save response for use in openid_form_user_register_form_alter().
$_SESSION['openid']['response'] = $response;
+ $form_state['values'] = array();
+ $form_state['values']['op'] = t('Create new account');
+ drupal_form_submit('user_register_form', $form_state);
+
+ if (!empty($form_state['user'])) {
+ module_invoke_all('openid_response', $response, $form_state['user']);
+ drupal_goto();
+ }
+
+ $messages = drupal_get_messages('error');
+ if (empty($form_state['values']['name']) || empty($form_state['values']['mail'])) {
+ // If the OpenID provider did not provide both a user name and an email
+ // address, ask the user to complete the registration manually instead of
+ // showing the error messages about the missing values generated by FAPI.
+ drupal_set_message(t('Complete the registration by filling out the form below. If you already have an account, you can <a href="@login">log in</a> now and add your OpenID under "My account".', array('@login' => url('user/login'))), 'warning');
+ }
+ else {
+ drupal_set_message(t('Account registration using the information provided by your OpenID provider failed due to the reasons listed below. Complete the registration by filling out the form below. If you already have an account, you can <a href="@login">log in</a> now and add your OpenID under "My account".', array('@login' => url('user/login'))), 'warning');
+ // Append form validation errors below the above warning.
+ foreach ($messages['error'] as $message) {
+ drupal_set_message( $message, 'error');
+ }
+ }
+
+ // We were unable to register a valid new user. Redirect to the normal
+ // registration page and prefill with the values we received.
$destination = drupal_get_destination();
unset($_GET['destination']);
drupal_goto('user/register', array('query' => $destination));