Commit 38e0ab1f authored by Dries's avatar Dries

- Patch #181578 by Moshe: removed distributed authentication code from...

- Patch #181578 by Moshe: removed distributed authentication code from user_save().  Factored the relevant code out to a separate function.
parent b05db1f1
......@@ -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']);
......
......@@ -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'));
}
......
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