Merge pull request #6979 from owncloud/share_api_error_codes

[ocs share api] use error code 403 if sharing is not permitted
remotes/origin/ldap_group_count
Thomas Müller 11 years ago
commit 75c8d74c94
  1. 10
      apps/files_sharing/lib/api.php

@ -162,7 +162,7 @@ class Api {
$view = new \OC\Files\View('/'.\OCP\User::getUser().'/files'); $view = new \OC\Files\View('/'.\OCP\User::getUser().'/files');
if(!$view->is_dir($path)) { if(!$view->is_dir($path)) {
return new \OC_OCS_Result(null, 404, "not a directory"); return new \OC_OCS_Result(null, 400, "not a directory");
} }
$content = $view->getDirectoryContent($path); $content = $view->getDirectoryContent($path);
@ -223,7 +223,7 @@ class Api {
$encryptionEnabled = \OC_App::isEnabled('files_encryption'); $encryptionEnabled = \OC_App::isEnabled('files_encryption');
if(isset($_POST['publicUpload']) && if(isset($_POST['publicUpload']) &&
($encryptionEnabled || $publicUploadEnabled !== 'yes')) { ($encryptionEnabled || $publicUploadEnabled !== 'yes')) {
return new \OC_OCS_Result(null, 404, "public upload disabled by the administrator"); return new \OC_OCS_Result(null, 403, "public upload disabled by the administrator");
} }
$publicUpload = isset($_POST['publicUpload']) ? $_POST['publicUpload'] : 'false'; $publicUpload = isset($_POST['publicUpload']) ? $_POST['publicUpload'] : 'false';
// read, create, update (7) if public upload is enabled or // read, create, update (7) if public upload is enabled or
@ -231,7 +231,7 @@ class Api {
$permissions = $publicUpload === 'true' ? 7 : 1; $permissions = $publicUpload === 'true' ? 7 : 1;
break; break;
default: default:
return new \OC_OCS_Result(null, 404, "unknown share type"); return new \OC_OCS_Result(null, 400, "unknown share type");
} }
try { try {
@ -243,7 +243,7 @@ class Api {
$permissions $permissions
); );
} catch (\Exception $e) { } catch (\Exception $e) {
return new \OC_OCS_Result(null, 404, $e->getMessage()); return new \OC_OCS_Result(null, 403, $e->getMessage());
} }
if ($token) { if ($token) {
@ -365,7 +365,7 @@ class Api {
$publicUploadEnabled = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes'); $publicUploadEnabled = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes');
$encryptionEnabled = \OC_App::isEnabled('files_encryption'); $encryptionEnabled = \OC_App::isEnabled('files_encryption');
if($encryptionEnabled || $publicUploadEnabled !== 'yes') { if($encryptionEnabled || $publicUploadEnabled !== 'yes') {
return new \OC_OCS_Result(null, 404, "public upload disabled by the administrator"); return new \OC_OCS_Result(null, 403, "public upload disabled by the administrator");
} }
if ($share['item_type'] !== 'folder' || if ($share['item_type'] !== 'folder' ||

Loading…
Cancel
Save