diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/openid/openid.inc | 2 | ||||
-rw-r--r-- | modules/openid/openid.module | 9 | ||||
-rw-r--r-- | modules/user/user.module | 36 |
3 files changed, 28 insertions, 19 deletions
diff --git a/modules/openid/openid.inc b/modules/openid/openid.inc index e54758a3c..7f525cf21 100644 --- a/modules/openid/openid.inc +++ b/modules/openid/openid.inc @@ -368,7 +368,7 @@ function _openid_get_bytes($num_bytes) { if (!isset($f)) { $f = @fopen(OPENID_RAND_SOURCE, "r"); } - if (!isset($f)) { + if (!$f) { // pseudorandom used $bytes = ''; for ($i = 0; $i < $num_bytes; $i += 4) { diff --git a/modules/openid/openid.module b/modules/openid/openid.module index 5be1fb137..8361ce62d 100644 --- a/modules/openid/openid.module +++ b/modules/openid/openid.module @@ -108,7 +108,7 @@ function openid_login_validate($form, &$form_state) { $return_to = url('', array('absolute' => TRUE)); } - openid_begin($form_state['values']['openid_url'], $return_to); + openid_begin($form_state['values']['openid_url'], $return_to, $form_state['values']); } /** @@ -191,7 +191,7 @@ function openid_user_delete($account, $aid = 0) { * @param $claimed_id The OpenID to authenticate * @param $return_to The endpoint to return to from the OpenID Provider */ -function openid_begin($claimed_id, $return_to = '') { +function openid_begin($claimed_id, $return_to = '', $form_values = array()) { include_once drupal_get_path('module', 'openid') .'/openid.inc'; $claimed_id = _openid_normalize($claimed_id); @@ -207,6 +207,9 @@ function openid_begin($claimed_id, $return_to = '') { $_SESSION['openid_op_endpoint'] = $op_endpoint; // Store the claimed_id in the session (for handling delegation). $_SESSION['openid_claimed_id'] = $claimed_id; + // Store the login form values so we can pass them to + // user_exteral_login later. + $_SESSION['openid_user_login_values'] = $form_values; // If bcmath is present, then create an association $assoc_handle = ''; @@ -398,7 +401,7 @@ function openid_authentication($response) { $account = user_external_load($identity); if (isset($account->uid)) { if (!variable_get('user_email_verification', TRUE) || $account->login) { - user_external_login($account); + user_external_login($account, $_SESSION['openid_user_login_values']); } else { drupal_set_message(t('You must validate your email address for this account before logging in via OpenID')); diff --git a/modules/user/user.module b/modules/user/user.module index 43a1fa07c..836263103 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -80,22 +80,28 @@ function user_external_load($authname) { } /** -* Perform standard Drupal login operations for a user object. The -* user object must already be authenticated. This function verifies -* that the user account is not blocked/denied and then performs the login, -* updates the login timestamp in the database, invokes hook_user('login'), -* regenerates the session, etc. -* -* @param $account -* An authenticated user object to be set as the currently logged -* in user. -* @return boolean -* TRUE if the login succeeds, FALSE otherwise. -*/ -function user_external_login($account) { + * Perform standard Drupal login operations for a user object. The + * user object must already be authenticated. This function verifies + * that the user account is not blocked/denied and then performs the login, + * updates the login timestamp in the database, invokes hook_user('login'), + * regenerates the session, etc. + * + * @param $account + * An authenticated user object to be set as the currently logged + * in user. + * @param $edit + * The array of form values submitted by the user, if any. + * @return boolean + * TRUE if the login succeeds, FALSE otherwise. + */ +function user_external_login($account, $edit = array()) { $form = drupal_get_form('user_login'); - $state = array(); + $state['values'] = $edit; + if (empty($state['values']['name'])) { + $state['values']['name'] = $account->name; + } + user_login_name_validate($form, $state, (array)$account); if (form_get_errors()) { return FALSE; @@ -1075,7 +1081,7 @@ function user_login_default_validators() { * * @return void **/ - function user_login_name_validate($form, &$form_state) { +function user_login_name_validate($form, &$form_state) { if (isset($form_state['values']['name'])) { if (user_is_blocked($form_state['values']['name'])) { // blocked in user administration |