Skip to content

Commit

Permalink
Prevent MNet error message when multiple records for the user are fou…
Browse files Browse the repository at this point in the history
…nd in mnet_session table
  • Loading branch information
mudrd8mz committed Nov 26, 2010
1 parent 35d76df commit ee4cd8f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions auth/mnet/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,16 @@ function update_enrolments($username, $courses) {
}
// 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
Expand Down

0 comments on commit ee4cd8f

Please sign in to comment.