From 38e0ab1f625d86505fabf22650b8203cb017e84c Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Mon, 18 Feb 2008 19:34:08 +0000 Subject: [PATCH] - Patch #181578 by Moshe: removed distributed authentication code from user_save(). Factored the relevant code out to a separate function. --- modules/openid/openid.module | 2 +- modules/user/user.module | 22 +++++----------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/modules/openid/openid.module b/modules/openid/openid.module index 69c98192203..3e456f2b901 100644 --- a/modules/openid/openid.module +++ b/modules/openid/openid.module @@ -403,7 +403,6 @@ function openid_authentication($response) { $form_state['values']['pass'] = user_password(); $form_state['values']['status'] = variable_get('user_register', 1) == 1; $form_state['values']['response'] = $response; - $form_state['values']['auth_openid'] = $identity; $form = drupal_retrieve_form('user_register', $form_state); drupal_prepare_form('user_register', $form, $form_state); drupal_validate_form('user_register', $form, $form_state); @@ -425,6 +424,7 @@ function openid_authentication($response) { drupal_set_message(t("Error saving user account."), 'error'); drupal_goto(); } + user_set_authmaps($account, array("authname_openid" => $identity)); user_external_login($account); } drupal_redirect_form($form, $form_state['redirect']); diff --git a/modules/user/user.module b/modules/user/user.module index f5d9d9bdd93..0effc2601c4 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -230,10 +230,9 @@ function user_save($account, $array = array(), $category = 'account') { $array['access'] = time(); } foreach ($array as $key => $value) { - // Fields that don't pertain to the users, users_roles, or - // authmap tables are automatically serialized into the - // users.data column. Authmap fields always begin with 'auth'. - if ($key != 'roles' && substr($key, 0, 4) !== 'auth' && empty($user_fields[$key])) { + // Fields that don't pertain to the users or user_roles + // automatically serialized into the users.data column. + if ($key != 'roles' && empty($user_fields[$key])) { if ($value === NULL) { unset($data[$key]); } @@ -314,7 +313,7 @@ function user_save($account, $array = array(), $category = 'account') { // fields from being saved there. $data = array(); foreach ($array as $key => $value) { - if ((substr($key, 0, 4) !== 'auth') && ($key != 'roles') && (empty($user_fields[$key])) && ($value !== NULL)) { + if (($key != 'roles') && (empty($user_fields[$key])) && ($value !== NULL)) { $data[$key] = $value; } } @@ -337,17 +336,6 @@ function user_save($account, $array = array(), $category = 'account') { $user = user_load(array('uid' => $array['uid'])); } - // Save distributed authentication mappings. - $authmaps = array(); - foreach ($array as $key => $value) { - if (substr($key, 0, 4) == 'auth') { - $authmaps[$key] = $value; - } - } - if (sizeof($authmaps) > 0) { - user_set_authmaps($user, $authmaps); - } - return $user; } @@ -1349,7 +1337,6 @@ function user_external_login_register($name, $module) { 'pass' => user_password(), 'init' => $name, 'status' => 1, - "authname_$module" => $name, 'access' => time() ); $account = user_save('', $userinfo); @@ -1358,6 +1345,7 @@ function user_external_login_register($name, $module) { drupal_set_message(t("Error saving user account."), 'error'); return; } + user_set_authmaps($account, array("authname_$module" => $name)); $user = $account; watchdog('user', 'New external user: %name using module %module.', array('%name' => $name, '%module' => $module), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $user->uid .'/edit')); }