diff options
author | yemkareems <yemkareems@gmail.com> | 2024-07-04 12:38:40 +0530 |
---|---|---|
committer | yemkareems <yemkareems@gmail.com> | 2024-07-08 15:42:55 +0530 |
commit | cfafbc84157a70557deca66e969b57912b66dc8f (patch) | |
tree | f8c972d4ee22e49755f0993b6f3678e7f46ede0b /apps/provisioning_api/lib | |
parent | 4c62f78a253c0dba05493bc6a325ab8c4083d65b (diff) | |
download | nextcloud-server-cfafbc84157a70557deca66e969b57912b66dc8f.tar.gz nextcloud-server-cfafbc84157a70557deca66e969b57912b66dc8f.zip |
fix: removed references to old disabled users code. refactored query as per getDisplayNames function. limit and offset added to query. default limit set to 25.
Signed-off-by: yemkareems <yemkareems@gmail.com>
Diffstat (limited to 'apps/provisioning_api/lib')
-rw-r--r-- | apps/provisioning_api/lib/Controller/UsersController.php | 31 |
1 files changed, 4 insertions, 27 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index 18c24f47cae..beb240681d0 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -278,7 +278,7 @@ class UsersController extends AUserData { * 200: Users details returned based on last logged in information */ public function getLastLoggedInUsers(string $search = '', - ?int $limit = null, + ?int $limit = 25, int $offset = 0, ): DataResponse { $currentUser = $this->userSession->getUser(); @@ -294,34 +294,11 @@ class UsersController extends AUserData { $users = []; - // Admin? Or SubAdmin? + // For Admin alone user sorting based on lastLogin. For sub admin and groups this is not supported $uid = $currentUser->getUID(); - $subAdminManager = $this->groupManager->getSubAdmin(); if ($this->groupManager->isAdmin($uid)) { $users = $this->userManager->getUsersSortedByLastLogin($limit, $offset, $search); $users = array_map(fn (IUser $user): string => $user->getUID(), $users); - } elseif ($subAdminManager->isSubAdmin($currentUser)) { - $subAdminOfGroups = $subAdminManager->getSubAdminsGroups($currentUser); - - $users = []; - /* We have to handle offset ourselve for correctness */ - $tempLimit = ($limit === null ? null : $limit + $offset); - foreach ($subAdminOfGroups as $group) { - $users = array_merge( - $users, - array_map( - fn (IUser $user): string => $user->getUID(), - array_filter( - $group->searchUsers($search, ($tempLimit === null ? null : $tempLimit - count($users))), - fn (IUser $user): bool => !$user->isEnabled() - ) - ) - ); - if (($tempLimit !== null) && (count($users) >= $tempLimit)) { - break; - } - } - $users = array_slice($users, $offset); } $usersDetails = []; @@ -332,13 +309,13 @@ class UsersController extends AUserData { // We still want to return all other accounts, but this one was removed from the backends // yet they are still in our database. Might be a LDAP remnant. $userData = null; - $this->logger->warning('Found one disabled account that was removed from its backend, but still exists in Nextcloud database', ['accountId' => $userId]); + $this->logger->warning('Found one account that was removed from its backend, but still exists in Nextcloud database', ['accountId' => $userId]); } // Do not insert empty entry if ($userData !== null) { $usersDetails[$userId] = $userData; } else { - // Currently logged in user does not have permissions to see this user + // Currently logged-in user does not have permissions to see this user // only showing its id $usersDetails[$userId] = ['id' => $userId]; } |