Commit c8c14b52 authored by Dries's avatar Dries

- Rollback of #637850: needs more review/discussion.

parent bead28a4
......@@ -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));
......
......@@ -254,11 +254,6 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase {
// Use a User-supplied Identity that is the URL of an XRDS document.
$identity = url('openid-test/yadis/xrds', array('absolute' => TRUE));
$this->submitLoginForm($identity);
$this->assertRaw(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'))), t('User was asked to complete the registration process.'));
// Submit the form using the default values based on SREG.
$this->drupalPost(NULL, array(), t('Create new account'));
$this->assertRaw(t('Once you have verified your e-mail address, you may log in via OpenID.'), t('User was asked to verify e-mail address.'));
$this->assertRaw(t('A welcome message with further instructions has been sent to your e-mail address.'), t('A welcome message was sent to the user.'));
......@@ -293,10 +288,6 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase {
// Use a User-supplied Identity that is the URL of an XRDS document.
$identity = url('openid-test/yadis/xrds', array('absolute' => TRUE));
$this->submitLoginForm($identity);
$this->assertRaw(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'))), t('User was asked to complete the registration process.'));
// Submit the form using the default values based on SREG.
$this->drupalPost(NULL, array(), t('Create new account'));
$this->assertLink('john', 0, t('User was logged in.'));
$user = user_load_by_name('john');
......@@ -322,10 +313,8 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase {
// Use a User-supplied Identity that is the URL of an XRDS document.
$identity = url('openid-test/yadis/xrds', array('absolute' => TRUE));
$this->submitLoginForm($identity);
$this->assertRaw(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'))), t('User was asked to complete the registration process.'));
// Submit the form using the default values based on SREG.
$this->drupalPost(NULL, array(), t('Create new account'));
$this->assertRaw(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'))), t('User was asked to complete the registration process manually.'));
$this->assertRaw(t('The name %name is already taken.', array('%name' => $web_user->name)), t('Form validation error for username was displayed.'));
$this->assertRaw(t('The e-mail address %mail is not valid.', array('%mail' => 'mail@invalid#')), t('Form validation error for e-mail address was displayed.'));
......@@ -360,12 +349,9 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase {
// Use a User-supplied Identity that is the URL of an XRDS document.
$identity = url('openid-test/yadis/xrds', array('absolute' => TRUE));
$this->submitLoginForm($identity);
$this->assertRaw(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'))), t('User was asked to complete the registration process.'));
// Submit the empty form.
$this->drupalPost(NULL, array(), t('Create new account'));
$this->assertRaw(t('Username field is required.'), t('Form validation error for username was displayed.'));
$this->assertRaw(t('E-mail address field is required.'), t('Form validation error for e-mail address was displayed.'));
$this->assertRaw(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'))), t('User was asked to complete the registration process manually.'));
$this->assertNoRaw(t('You must enter a username.'), t('Form validation error for username was not displayed.'));
$this->assertNoRaw(t('You must enter an e-mail address.'), t('Form validation error for e-mail address was not displayed.'));
// Enter username and e-mail address manually.
$edit = array('name' => 'john', 'mail' => 'john@example.com');
......@@ -405,10 +391,6 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase {
// Use a User-supplied Identity that is the URL of an XRDS document.
$identity = url('openid-test/yadis/xrds', array('absolute' => TRUE));
$this->submitLoginForm($identity);
$this->assertRaw(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'))), t('User was asked to complete the registration process.'));
// Submit the form using the default values based on AX.
$this->drupalPost(NULL, array(), t('Create new account'));
$this->assertLink('john', 0, t('User was logged in.'));
$user = user_load_by_name('john');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment