Skip to content

Commit

Permalink
Check that we have a valid Joomla user. See GitHub Issue #3682.
Browse files Browse the repository at this point in the history
  • Loading branch information
campbell-m committed Jun 11, 2024
1 parent 1a3299e commit 547b72f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions web/lib/MRBS/Auth/AuthJoomla.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,21 @@ public function getUsernames() : array
{
$user = Factory::getUser((int)$user_id);
}
$result[] = array('username' => $user->username,
'display_name' => $user->name);
// Check to see that the user has a username. The result of getUser() on a user_id that doesn't exist is,
// strangely, a user object with all properties set to null. In theory (?) all the user_ids returned by
// getUsersByGroup() should exist, but there has been a case where this is not so. See
// https://github.com/meeting-room-booking-system/mrbs-code/issues/3682 .
if (isset($user->username))
{
$result[] = array(
'username' => $user->username,
'display_name' => $user->name
);
}
else
{
trigger_error("The Joomla user with id $user_id appears in Joomla groups but not in Joomla users.", E_USER_WARNING);
}
}

// Need to sort the users
Expand Down

0 comments on commit 547b72f

Please sign in to comment.