Commit c98ea18b authored by Richard Mansfield's avatar Richard Mansfield

Fix for find_remote_user when 2 xmlrpc users with the same username are both...

Fix for find_remote_user when 2 xmlrpc users with the same username are both in 'No institution' (bug #548181)
Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 55c9edbb
......@@ -133,7 +133,6 @@ function find_remote_user($username, $wwwroot) {
$authinstances = auth_get_auth_instances_for_institution($institution);
$candidates = array();
$auths = array();
$aiid = 'ai.id';
if (!is_mysql()) {
......@@ -164,20 +163,30 @@ function find_remote_user($username, $wwwroot) {
try {
$user = new User;
$user->find_by_instanceid_username($authinstance->id, $username, true);
$candidates[$user->id] = $user;
$auths[] = $authinstance->id;
$candidates[$authinstance->id] = $user;
} catch (Exception $e) {
// we don't care
continue;
}
}
if (count($candidates) > 1) {
if (!$wwwrootauths = get_column('auth_instance_config', 'instance', 'value', $wwwroot, 'field', 'wwwroot')) {
return false;
}
foreach (array_keys($candidates) as $a) {
if (!in_array($a, $wwwrootauths)) {
unset($candidates[$a]);
}
}
}
if (count($candidates) != 1) {
return false;
}
safe_require('auth', 'xmlrpc');
return array(array_pop($candidates), new AuthXmlrpc(array_pop($auths)));
return array(end($candidates), new AuthXmlrpc(key($candidates)));
}
function fetch_user_image($username) {
......
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