From 0639f09175921a9ce6bb27fdb653f803882fd0b2 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 26 Oct 2020 14:39:39 +0100 Subject: [PATCH] Do not show shares of disabled users If a user is disabled their shares should be disabled as well. This makes sure that if the owner of a share is disabled nobody receives those shares anymore. The sharer can be disabled as it is not their data that is shared. Signed-off-by: Roeland Jago Douma --- apps/files_sharing/lib/MountProvider.php | 32 ++++++++++++++++-------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/apps/files_sharing/lib/MountProvider.php b/apps/files_sharing/lib/MountProvider.php index 3e703a4a6b..aa5f123d48 100644 --- a/apps/files_sharing/lib/MountProvider.php +++ b/apps/files_sharing/lib/MountProvider.php @@ -35,34 +35,33 @@ use OCP\Files\Storage\IStorageFactory; use OCP\IConfig; use OCP\ILogger; use OCP\IUser; +use OCP\IUserManager; use OCP\Share\IManager; use OCP\Share\IShare; class MountProvider implements IMountProvider { - /** - * @var \OCP\IConfig - */ + /** @var \OCP\IConfig */ protected $config; - /** - * @var IManager - */ + /** @var IManager */ protected $shareManager; - /** - * @var ILogger - */ + /** @var ILogger */ protected $logger; + /** @var IUserManager */ + private $userManager; + /** * @param \OCP\IConfig $config * @param IManager $shareManager * @param ILogger $logger */ - public function __construct(IConfig $config, IManager $shareManager, ILogger $logger) { + public function __construct(IConfig $config, IManager $shareManager, ILogger $logger, IUserManager $userManager) { $this->config = $config; $this->shareManager = $shareManager; $this->logger = $logger; + $this->userManager = $userManager; } @@ -86,6 +85,19 @@ class MountProvider implements IMountProvider { $superShares = $this->buildSuperShares($shares, $user); + $superShares = array_filter($superShares, function (array $share) { + $user = $this->userManager->get($share[0]->getShareOwner()); + if ($user === null) { + return false; + } + + if ($user->isEnabled() === false) { + return false; + } + + return true; + }); + $mounts = []; $view = new View('/' . $user->getUID() . '/files'); $ownerViews = [];