Merge pull request #22355 from nextcloud/backport/20772/stable19

[stable19] Properly search for users when limittogroups is enabled
This commit is contained in:
Roeland Jago Douma 2020-08-24 09:12:13 +02:00 committed by GitHub
commit 9aac6d9251
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -79,7 +79,15 @@ class UserPlugin implements ISearchPlugin {
$usersInGroup = $this->groupManager->displayNamesInGroup($userGroupId, $search, $limit, $offset); $usersInGroup = $this->groupManager->displayNamesInGroup($userGroupId, $search, $limit, $offset);
foreach ($usersInGroup as $userId => $displayName) { foreach ($usersInGroup as $userId => $displayName) {
$userId = (string) $userId; $userId = (string) $userId;
$users[$userId] = $this->userManager->get($userId); $user = $this->userManager->get($userId);
if (!$user->isEnabled()) {
// Ignore disabled users
continue;
}
$users[$userId] = $user;
}
if (count($usersInGroup) >= $limit) {
$hasMoreResults = true;
} }
} }
} else { } else {

View File

@ -321,7 +321,7 @@ class UserPluginTest extends TestCase {
['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']], ['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
], ],
false, true,
false, false,
[ [
['test1', $this->getUserMock('test1', 'Test One')], ['test1', $this->getUserMock('test1', 'Test One')],