Index: modules/openid/openid.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/openid/openid.module,v
retrieving revision 1.81
diff -u -9 -p -r1.81 openid.module
--- modules/openid/openid.module	6 Apr 2010 06:53:55 -0000	1.81
+++ modules/openid/openid.module	6 Apr 2010 19:09:29 -0000
@@ -621,49 +621,23 @@ function openid_authentication($response
         // Let other modules act on OpenID login
         module_invoke_all('openid_response', $response, $account);
       }
     }
     else {
       drupal_set_message(t('You must validate your email address for this account before logging in via OpenID.'));
     }
   }
   elseif (variable_get('user_register', 1)) {
-    // Register new user.
+    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'))));
 
     // 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));
   }
   else {
     drupal_set_message(t('Only site administrators can create new user accounts.'), 'error');
   }
   drupal_goto();
 }
Index: modules/openid/openid.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/openid/openid.test,v
retrieving revision 1.20
diff -u -9 -p -r1.20 openid.test
--- modules/openid/openid.test	6 Apr 2010 06:53:55 -0000	1.20
+++ modules/openid/openid.test	6 Apr 2010 19:09:29 -0000
@@ -248,18 +248,23 @@ class OpenIDRegistrationTestCase extends
   function testRegisterUserWithEmailVerification() {
     variable_set('user_email_verification', TRUE);
 
     // Tell openid_test.module to respond with these SREG fields.
     variable_set('openid_test_response', array('openid.sreg.nickname' => 'john', 'openid.sreg.email' => 'john@example.com'));
 
     // 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.'));
 
     $user = user_load_by_name('john');
     $this->assertTrue($user, t('User was registered with right username.'));
     $this->assertEqual($user->mail, 'john@example.com', t('User was registered with right email address.'));
     $this->assertFalse($user->data, t('No additional user info was saved.'));
 
     $this->submitLoginForm($identity);
@@ -282,18 +287,22 @@ class OpenIDRegistrationTestCase extends
   function testRegisterUserWithoutEmailVerification() {
     variable_set('user_email_verification', FALSE);
 
     // Tell openid_test.module to respond with these SREG fields.
     variable_set('openid_test_response', array('openid.sreg.nickname' => 'john', 'openid.sreg.email' => 'john@example.com'));
 
     // 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');
     $this->assertTrue($user, t('User was registered with right username.'));
     $this->assertEqual($user->mail, 'john@example.com', t('User was registered with right email address.'));
     $this->assertFalse($user->data, t('No additional user info was saved.'));
 
     $this->drupalLogout();
 
@@ -307,20 +316,22 @@ class OpenIDRegistrationTestCase extends
    */
   function testRegisterUserWithInvalidSreg() {
     // Tell openid_test.module to respond with these SREG fields.
     $web_user = $this->drupalCreateUser(array());
     variable_set('openid_test_response', array('openid.sreg.nickname' => $web_user->name, 'openid.sreg.email' => 'mail@invalid#'));
 
     // 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.'));
 
-    $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.'));
+    // Submit the form using the default values based on SREG.
+    $this->drupalPost(NULL, array(), t('Create new account'));
     $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.'));
 
     // Enter username and e-mail address manually.
     $edit = array('name' => 'john', 'mail' => 'john@example.com');
     $this->drupalPost(NULL, $edit, 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.'));
 
     $user = user_load_by_name('john');
@@ -343,21 +354,24 @@ class OpenIDRegistrationTestCase extends
    * information (i.e. no username or e-mail address).
    */
   function testRegisterUserWithoutSreg() {
     // Load the front page to get the user login block.
     $this->drupalGet('');
 
     // 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 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.'));
+    $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.'));
 
     // Enter username and e-mail address manually.
     $edit = array('name' => 'john', 'mail' => 'john@example.com');
     $this->drupalPost(NULL, $edit, 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.'));
 
     $user = user_load_by_name('john');
     $this->assertTrue($user, t('User was registered with right username.'));
     $this->assertFalse($user->data, t('No additional user info was saved.'));
@@ -385,18 +399,22 @@ class OpenIDRegistrationTestCase extends
       'openid.ns.ext123' => 'http://openid.net/srv/ax/1.0',
       'openid.ext123.value.mail_ao' => 'john@example.com',
       'openid.ext123.count.name_son' => '1',
       'openid.ext123.value.name_son.1' => 'john',
     ));
 
     // 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');
     $this->assertTrue($user, t('User was registered with right username.'));
     $this->assertEqual($user->mail, 'john@example.com', t('User was registered with right email address.'));
   }
 }
 
 /**
