From ee4cd8f16d4fc193c0407b7e5452834f387ee7b7 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Fri, 26 Nov 2010 09:20:06 +0000 Subject: [PATCH] Prevent MNet error message when multiple records for the user are found in mnet_session table --- auth/mnet/auth.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/auth/mnet/auth.php b/auth/mnet/auth.php index 183742a70cf..84bbbbc9df2 100644 --- a/auth/mnet/auth.php +++ b/auth/mnet/auth.php @@ -464,9 +464,16 @@ class auth_plugin_mnet extends auth_plugin_base { } // make sure it is a user we have an in active session // with that host... - if (!$userid = $DB->get_field('mnet_session', 'userid', - array('username'=>$username, 'mnethostid'=>$remoteclient->id))) { - throw new mnet_server_exception(1, 'authfail_nosessionexists'); + $mnetsessions = $DB->get_records('mnet_session', array('username' => $username, 'mnethostid' => $remoteclient->id), '', 'id, userid'); + $userid = null; + foreach ($mnetsessions as $mnetsession) { + if (is_null($userid)) { + $userid = $mnetsession->userid; + continue; + } + if ($userid != $mnetsession->userid) { + throw new mnet_server_exception(3, 'authfail_usermismatch'); + } } if (empty($courses)) { // no courses? clear out quickly