diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-02-16 10:22:49 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-02-16 10:22:49 +0100 |
commit | ed6843e87b03aa7e2a631bd8b97085380023b4ba (patch) | |
tree | 46e9d8c1f1dc6b2b2ab282dd1e9130fdff9828e8 /lib/private/share20 | |
parent | 3837cb95fde8b1b89b037a5e1dee303b0fd3272c (diff) | |
download | nextcloud-server-ed6843e87b03aa7e2a631bd8b97085380023b4ba.tar.gz nextcloud-server-ed6843e87b03aa7e2a631bd8b97085380023b4ba.zip |
Return proper error string if sharing for this user is disabled
Fixes #22402
Diffstat (limited to 'lib/private/share20')
-rw-r--r-- | lib/private/share20/manager.php | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php index 7a10d6cba55..4cff3dc818b 100644 --- a/lib/private/share20/manager.php +++ b/lib/private/share20/manager.php @@ -455,18 +455,16 @@ class Manager implements IManager { * Check if the user that is sharing can actually share * * @param \OCP\Share\IShare $share - * @return bool + * @throws \Exception */ protected function canShare(\OCP\Share\IShare $share) { if (!$this->shareApiEnabled()) { - return false; + throw new \Exception('The share API is disabled'); } if ($this->sharingDisabledForUser($share->getSharedBy())) { - return false; + throw new \Exception('You are not allowed to share'); } - - return true; } /** @@ -479,9 +477,7 @@ class Manager implements IManager { * TODO: handle link share permissions or check them */ public function createShare(\OCP\Share\IShare $share) { - if (!$this->canShare($share)) { - throw new \Exception('The Share API is disabled'); - } + $this->canShare($share); $this->generalCreateChecks($share); @@ -592,9 +588,7 @@ class Manager implements IManager { public function updateShare(\OCP\Share\IShare $share) { $expirationDateUpdated = false; - if (!$this->canShare($share)) { - throw new \Exception('The Share API is disabled'); - } + $this->canShare($share); try { $originalShare = $this->getShareById($share->getFullId()); |