summaryrefslogtreecommitdiffstats
path: root/lib/private/Share20
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2017-04-25 14:12:44 +0200
committerGitHub <noreply@github.com>2017-04-25 14:12:44 +0200
commit82c9eb1c5654562e8057953356af49b7295a7561 (patch)
tree852acfbf17793033f932fed8da3a39b5f242c812 /lib/private/Share20
parent026070a2fc3b766f9d686c50c358b6f03462ad18 (diff)
parent58cc1251be33b43a5bb9163e1b042970b8e81b4b (diff)
downloadnextcloud-server-82c9eb1c5654562e8057953356af49b7295a7561.tar.gz
nextcloud-server-82c9eb1c5654562e8057953356af49b7295a7561.zip
Merge pull request #4462 from danxuliu/fix-sharing-password-protected-link
Fix sharing a password protected link
Diffstat (limited to 'lib/private/Share20')
-rw-r--r--lib/private/Share20/Manager.php55
1 files changed, 31 insertions, 24 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 41512d66159..06d03f2ec7c 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -713,36 +713,17 @@ class Manager implements IManager {
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
$this->linkCreateChecks($share);
- // Password updated.
- if ($share->getPassword() !== $originalShare->getPassword()) {
- //Verify the password
- $this->verifyPassword($share->getPassword());
-
- // If a password is set. Hash it!
- if ($share->getPassword() !== null) {
- $share->setPassword($this->hasher->hash($share->getPassword()));
- }
- }
+ $this->updateSharePasswordIfNeeded($share, $originalShare);
if ($share->getExpirationDate() != $originalShare->getExpirationDate()) {
//Verify the expiration date
$this->validateExpirationDate($share);
$expirationDateUpdated = true;
}
- }
-
- $plainTextPassword = null;
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK || $share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) {
- // Password updated.
- if ($share->getPassword() !== $originalShare->getPassword()) {
- //Verify the password
- $this->verifyPassword($share->getPassword());
-
- // If a password is set. Hash it!
- if ($share->getPassword() !== null) {
- $plainTextPassword = $share->getPassword();
- $share->setPassword($this->hasher->hash($plainTextPassword));
- }
+ } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) {
+ $plainTextPassword = $share->getPassword();
+ if (!$this->updateSharePasswordIfNeeded($share, $originalShare)) {
+ $plainTextPassword = null;
}
}
@@ -796,6 +777,32 @@ class Manager implements IManager {
}
/**
+ * Updates the password of the given share if it is not the same as the
+ * password of the original share.
+ *
+ * @param \OCP\Share\IShare $share the share to update its password.
+ * @param \OCP\Share\IShare $originalShare the original share to compare its
+ * password with.
+ * @return boolean whether the password was updated or not.
+ */
+ private function updateSharePasswordIfNeeded(\OCP\Share\IShare $share, \OCP\Share\IShare $originalShare) {
+ // Password updated.
+ if ($share->getPassword() !== $originalShare->getPassword()) {
+ //Verify the password
+ $this->verifyPassword($share->getPassword());
+
+ // If a password is set. Hash it!
+ if ($share->getPassword() !== null) {
+ $share->setPassword($this->hasher->hash($share->getPassword()));
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
* Delete all the children of this share
* FIXME: remove once https://github.com/owncloud/core/pull/21660 is in
*