]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: limit and fixLimit removed. negative limit handled in controller. removed getUse...
authoryemkareems <yemkareems@gmail.com>
Thu, 4 Jul 2024 09:11:05 +0000 (14:41 +0530)
committeryemkareems <yemkareems@gmail.com>
Mon, 8 Jul 2024 10:12:55 +0000 (15:42 +0530)
Signed-off-by: yemkareems <yemkareems@gmail.com>
apps/provisioning_api/lib/Controller/UsersController.php
lib/private/AllConfig.php
lib/private/User/Manager.php
lib/public/IUserManager.php

index 66cce405335604c0f32426e9a1d82933f6dbc1d1..1d3c1006a59ff707812de1b9b056dc4e65249c33 100644 (file)
@@ -266,9 +266,7 @@ class UsersController extends AUserData {
        }
 
        /**
-        * @NoAdminRequired
-        *
-        * Get the list of last logged-in users and their details
+        * Gets the list of users sorted by lastLogin, from most recent to least recent
         *
         * @param string $search Text to search for
         * @param ?int $limit Limit the amount of users returned
@@ -278,8 +276,8 @@ class UsersController extends AUserData {
         * 200: Users details returned based on last logged in information
         */
        public function getLastLoggedInUsers(string $search = '',
-               ?int   $limit = null,
-               int    $offset = 0,
+               ?int $limit = null,
+               int $offset = 0,
        ): DataResponse {
                $currentUser = $this->userSession->getUser();
                if ($currentUser === null) {
@@ -295,11 +293,7 @@ class UsersController extends AUserData {
                $users = [];
 
                // For Admin alone user sorting based on lastLogin. For sub admin and groups this is not supported
-               $uid = $currentUser->getUID();
-               if ($this->groupManager->isAdmin($uid)) {
-                       $users = $this->userManager->getUsersSortedByLastLogin($limit, $offset, $search);
-                       $users = array_map(fn (IUser $user): string => $user->getUID(), $users);
-               }
+               $users = $this->config->getLastLoggedInUsers($limit, $offset, $search);
 
                $usersDetails = [];
                foreach ($users as $userId) {
index 78546531dc697ffca8d0d974d1014ca7554a3ab8..f39182683f58c0163f069f1a6dc1a91896e17894 100644 (file)
@@ -492,7 +492,7 @@ class AllConfig implements IConfig {
        }
 
        /**
-        * Gets the list of users based on their lastLogin info asc or desc
+        * Gets the list of user ids sorted by lastLogin, from most recent to least recent
         *
         * @param int|null $limit how many users to fetch
         * @param int $offset from which offset to fetch
@@ -500,7 +500,6 @@ class AllConfig implements IConfig {
         * @return array of user IDs
         */
        public function getLastLoggedInUsers(?int $limit = null, int $offset = 0, string $search = ''): array {
-               $limit = $this->fixLimit($limit);
                // TODO - FIXME
                $this->fixDIInit();
 
@@ -574,12 +573,4 @@ class AllConfig implements IConfig {
        public function getSystemConfig() {
                return $this->systemConfig;
        }
-
-       private function fixLimit($limit) {
-               if (is_int($limit) && $limit >= 0) {
-                       return $limit;
-               }
-
-               return null;
-       }
 }
index aeadb338ea009ae7cb4c195cf43920b4cbbba1e5..d93431a2699f40b4546aa02b88d207968e6419e2 100644 (file)
@@ -342,21 +342,6 @@ class Manager extends PublicEmitter implements IUserManager {
                return array_slice($users, $offset, $limit);
        }
 
-       /**
-        * @return IUser[]
-        */
-       public function getUsersSortedByLastLogin(?int $limit = null, int $offset = 0, $search = ''): array {
-               $users = $this->config->getLastLoggedInUsers($limit, $offset, $search);
-               return array_combine(
-                       $users,
-                       array_map(
-                               fn (string $uid): IUser => new LazyUser($uid, $this),
-                               $users
-                       )
-               );
-       }
-
-
        /**
         * Search known users (from phonebook sync) by displayName
         *
index 8b080fd75c58607866bb59a0744a7ec79f972622..851b565f617464eb33f408d7ab57df81b47f0e1f 100644 (file)
@@ -124,11 +124,6 @@ interface IUserManager {
         */
        public function getDisabledUsers(?int $limit = null, int $offset = 0, string $search = ''): array;
 
-       /**
-        * @return IUser[]
-        * @since 30.0.0
-        */
-       public function getUsersSortedByLastLogin(?int $limit = null, int $offset = 0, $search = ''): array;
        /**
         * Search known users (from phonebook sync) by displayName
         *