diff options
Diffstat (limited to 'lib/private/Share20/Manager.php')
-rw-r--r-- | lib/private/Share20/Manager.php | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 2c08e616f82..9383255bc73 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -26,6 +26,7 @@ namespace OC\Share20; use OC\Cache\CappedMemoryCache; use OC\Files\Mount\MoveableMount; +use OC\HintException; use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IRootFolder; @@ -42,6 +43,8 @@ use OCP\Share\Exceptions\GenericShareException; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; use OCP\Share\IProviderFactory; +use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\GenericEvent; /** * This class is the communication hub for all sharing related operations. @@ -70,6 +73,8 @@ class Manager implements IManager { private $rootFolder; /** @var CappedMemoryCache */ private $sharingDisabledForUsersCache; + /** @var EventDispatcher */ + private $eventDispatcher; /** @@ -85,6 +90,7 @@ class Manager implements IManager { * @param IProviderFactory $factory * @param IUserManager $userManager * @param IRootFolder $rootFolder + * @param EventDispatcher $eventDispatcher */ public function __construct( ILogger $logger, @@ -96,7 +102,8 @@ class Manager implements IManager { IL10N $l, IProviderFactory $factory, IUserManager $userManager, - IRootFolder $rootFolder + IRootFolder $rootFolder, + EventDispatcher $eventDispatcher ) { $this->logger = $logger; $this->config = $config; @@ -108,6 +115,7 @@ class Manager implements IManager { $this->factory = $factory; $this->userManager = $userManager; $this->rootFolder = $rootFolder; + $this->eventDispatcher = $eventDispatcher; $this->sharingDisabledForUsersCache = new CappedMemoryCache(); } @@ -138,16 +146,11 @@ class Manager implements IManager { } // Let others verify the password - $accepted = true; - $message = ''; - \OCP\Util::emitHook('\OC\Share', 'verifyPassword', [ - 'password' => $password, - 'accepted' => &$accepted, - 'message' => &$message - ]); - - if (!$accepted) { - throw new \Exception($message); + try { + $event = new GenericEvent($password); + $this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event); + } catch (HintException $e) { + throw new \Exception($e->getHint()); } } @@ -242,8 +245,11 @@ class Manager implements IManager { throw new GenericShareException($message_t, $message_t, 404); } + // Check that read permissions are always set - if (($share->getPermissions() & \OCP\Constants::PERMISSION_READ) === 0) { + // Link shares are allowed to have no read permissions to allow upload to hidden folders + if ($share->getShareType() !== \OCP\Share::SHARE_TYPE_LINK && + ($share->getPermissions() & \OCP\Constants::PERMISSION_READ) === 0) { throw new \InvalidArgumentException('Shares need at least read permissions'); } |