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 <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2020-10-26 14:39:39 +01:00
parent 9976e47035
commit 0639f09175
No known key found for this signature in database
GPG Key ID: F941078878347C0C
1 changed files with 22 additions and 10 deletions

View File

@ -35,34 +35,33 @@ use OCP\Files\Storage\IStorageFactory;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger; use OCP\ILogger;
use OCP\IUser; use OCP\IUser;
use OCP\IUserManager;
use OCP\Share\IManager; use OCP\Share\IManager;
use OCP\Share\IShare; use OCP\Share\IShare;
class MountProvider implements IMountProvider { class MountProvider implements IMountProvider {
/** /** @var \OCP\IConfig */
* @var \OCP\IConfig
*/
protected $config; protected $config;
/** /** @var IManager */
* @var IManager
*/
protected $shareManager; protected $shareManager;
/** /** @var ILogger */
* @var ILogger
*/
protected $logger; protected $logger;
/** @var IUserManager */
private $userManager;
/** /**
* @param \OCP\IConfig $config * @param \OCP\IConfig $config
* @param IManager $shareManager * @param IManager $shareManager
* @param ILogger $logger * @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->config = $config;
$this->shareManager = $shareManager; $this->shareManager = $shareManager;
$this->logger = $logger; $this->logger = $logger;
$this->userManager = $userManager;
} }
@ -86,6 +85,19 @@ class MountProvider implements IMountProvider {
$superShares = $this->buildSuperShares($shares, $user); $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 = []; $mounts = [];
$view = new View('/' . $user->getUID() . '/files'); $view = new View('/' . $user->getUID() . '/files');
$ownerViews = []; $ownerViews = [];