]> source.dussan.org Git - nextcloud-server.git/commitdiff
Set files_sharing:hide_disabled_user_shares to 'yes' to hide shares from disabled...
authorCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 3 Aug 2023 14:13:38 +0000 (16:13 +0200)
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>
Mon, 18 Sep 2023 10:38:22 +0000 (10:38 +0000)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
lib/private/Share20/Manager.php

index 5e60a950fdb760657fa632786cbf5a2612ea7e5b..9ed3ef46c97356ff90c13cf1d330f70551090fca 100644 (file)
@@ -1347,7 +1347,7 @@ class Manager implements IManager {
                        $added = 0;
                        foreach ($shares as $share) {
                                try {
-                                       $this->checkExpireDate($share);
+                                       $this->checkShare($share);
                                } catch (ShareNotFound $e) {
                                        //Ignore since this basically means the share is deleted
                                        continue;
@@ -1406,7 +1406,7 @@ class Manager implements IManager {
                // remove all shares which are already expired
                foreach ($shares as $key => $share) {
                        try {
-                               $this->checkExpireDate($share);
+                               $this->checkShare($share);
                        } catch (ShareNotFound $e) {
                                unset($shares[$key]);
                        }
@@ -1452,7 +1452,7 @@ class Manager implements IManager {
 
                $share = $provider->getShareById($id, $recipient);
 
-               $this->checkExpireDate($share);
+               $this->checkShare($share);
 
                return $share;
        }
@@ -1536,7 +1536,7 @@ class Manager implements IManager {
                        throw new ShareNotFound($this->l->t('The requested share does not exist anymore'));
                }
 
-               $this->checkExpireDate($share);
+               $this->checkShare($share);
 
                /*
                 * Reduce the permissions for link or email shares if public upload is not enabled
@@ -1549,11 +1549,25 @@ class Manager implements IManager {
                return $share;
        }
 
-       protected function checkExpireDate($share) {
+       /**
+        * Check expire date and disabled owner
+        *
+        * @throws ShareNotFound
+        */
+       protected function checkShare(IShare $share): void {
                if ($share->isExpired()) {
                        $this->deleteShare($share);
                        throw new ShareNotFound($this->l->t('The requested share does not exist anymore'));
                }
+               if ($this->config->getAppValue('files_sharing', 'hide_disabled_user_shares', 'no') === 'yes') {
+                       $uids = array_unique([$share->getShareOwner(),$share->getSharedBy()]);
+                       foreach ($uids as $uid) {
+                               $user = $this->userManager->get($uid);
+                               if (($user !== null) && !$user->isEnabled()) {
+                                       throw new ShareNotFound($this->l->t('The requested share comes from a disabled user'));
+                               }
+                       }
+               }
        }
 
        /**