aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-07-06 12:48:26 +0200
committerGitHub <noreply@github.com>2016-07-06 12:48:26 +0200
commit38645553901689f73f58a3e06873d581c77cb55a (patch)
treed7b5f21c0296d795c211ab850fa202969e190b6c
parenta2e057398739f699d1b361c6371607ce556f8eea (diff)
parentffe1a8bffc9a459b15d3b07fdc3f89a2857e27ac (diff)
downloadnextcloud-server-38645553901689f73f58a3e06873d581c77cb55a.tar.gz
nextcloud-server-38645553901689f73f58a3e06873d581c77cb55a.zip
Merge pull request #25360 from owncloud/stable9-backportshareownerfix
[stable9] Change order of share creation validation
-rw-r--r--build/integration/features/sharing-v1.feature15
-rw-r--r--lib/private/share20/manager.php36
2 files changed, 33 insertions, 18 deletions
diff --git a/build/integration/features/sharing-v1.feature b/build/integration/features/sharing-v1.feature
index 56399eefdb0..ed8f3b23f25 100644
--- a/build/integration/features/sharing-v1.feature
+++ b/build/integration/features/sharing-v1.feature
@@ -26,6 +26,21 @@ Feature: sharing
Then the OCS status code should be "100"
And the HTTP status code should be "200"
+ Scenario: Creating a new share with user who already received a share through their group
+ Given As an "admin"
+ And user "user0" exists
+ And user "user1" exists
+ And group "sharing-group" exists
+ And user "user1" belongs to group "sharing-group"
+ And file "welcome.txt" of user "user0" is shared with group "sharing-group"
+ And As an "user0"
+ Then sending "POST" to "/apps/files_sharing/api/v1/shares" with
+ | path | welcome.txt |
+ | shareWith | user1 |
+ | shareType | 0 |
+ Then the OCS status code should be "100"
+ And the HTTP status code should be "200"
+
Scenario: Creating a new public share
Given user "user0" exists
And As an "user0"
diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php
index 7a48de6a11c..b00f7ccd5b6 100644
--- a/lib/private/share20/manager.php
+++ b/lib/private/share20/manager.php
@@ -505,6 +505,24 @@ class Manager implements IManager {
$this->generalCreateChecks($share);
+ // Verify if there are any issues with the path
+ $this->pathCreateChecks($share->getNode());
+
+ /*
+ * On creation of a share the owner is always the owner of the path
+ * Except for mounted federated shares.
+ */
+ $storage = $share->getNode()->getStorage();
+ if ($storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
+ $parent = $share->getNode()->getParent();
+ while($parent->getStorage()->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
+ $parent = $parent->getParent();
+ }
+ $share->setShareOwner($parent->getOwner()->getUID());
+ } else {
+ $share->setShareOwner($share->getNode()->getOwner()->getUID());
+ }
+
//Verify share type
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
$this->userCreateChecks($share);
@@ -538,24 +556,6 @@ class Manager implements IManager {
}
}
- // Verify if there are any issues with the path
- $this->pathCreateChecks($share->getNode());
-
- /*
- * On creation of a share the owner is always the owner of the path
- * Except for mounted federated shares.
- */
- $storage = $share->getNode()->getStorage();
- if ($storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
- $parent = $share->getNode()->getParent();
- while($parent->getStorage()->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
- $parent = $parent->getParent();
- }
- $share->setShareOwner($parent->getOwner()->getUID());
- } else {
- $share->setShareOwner($share->getNode()->getOwner()->getUID());
- }
-
// Cannot share with the owner
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
$share->getSharedWith() === $share->getShareOwner()) {