summaryrefslogtreecommitdiff
path: root/modules/openid
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-04-07 07:09:17 +0000
committerDries Buytaert <dries@buytaert.net>2010-04-07 07:09:17 +0000
commit4c3660a69a55a2f46599b2fe5dea5bc9a3f2e40e (patch)
tree9f94771678471807d7538f0a28ba83279e33030d /modules/openid
parent97c14a993ee998e8856d940c9f3fd35b520f4362 (diff)
downloadbrdo-4c3660a69a55a2f46599b2fe5dea5bc9a3f2e40e.tar.gz
brdo-4c3660a69a55a2f46599b2fe5dea5bc9a3f2e40e.tar.bz2
- Patch #637850 by c960657: removed duplicated code and improved tests.
Diffstat (limited to 'modules/openid')
-rw-r--r--modules/openid/openid.module28
-rw-r--r--modules/openid/openid.test26
2 files changed, 23 insertions, 31 deletions
diff --git a/modules/openid/openid.module b/modules/openid/openid.module
index 96a74415a..92f477dd2 100644
--- a/modules/openid/openid.module
+++ b/modules/openid/openid.module
@@ -627,37 +627,11 @@ function openid_authentication($response) {
}
}
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));
diff --git a/modules/openid/openid.test b/modules/openid/openid.test
index f507fcdae..3ddc5f551 100644
--- a/modules/openid/openid.test
+++ b/modules/openid/openid.test
@@ -254,6 +254,11 @@ 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.'));
@@ -288,6 +293,10 @@ 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');
@@ -313,8 +322,10 @@ 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.'));
- $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.'));
@@ -349,9 +360,12 @@ 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 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');
@@ -391,6 +405,10 @@ 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');