diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-05-29 21:35:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-29 21:35:57 +0200 |
commit | 555108dc65501ba08d0b70c05e0eaebd6379c4b1 (patch) | |
tree | a862562dc159c0f14178c9116d577e2304cbfc90 /lib/private/Share20 | |
parent | c31b2d6ce15a71b681eabadcc4fce6d0f98f5cb2 (diff) | |
download | nextcloud-server-555108dc65501ba08d0b70c05e0eaebd6379c4b1.tar.gz nextcloud-server-555108dc65501ba08d0b70c05e0eaebd6379c4b1.zip |
Revert "[stable18] Fix password changes in link and mail shares"
Diffstat (limited to 'lib/private/Share20')
-rw-r--r-- | lib/private/Share20/Manager.php | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index fead605eb03..73860fd39f4 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -972,14 +972,8 @@ class Manager implements IManager { } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { $this->linkCreateChecks($share); - $plainTextPassword = $share->getPassword(); - $this->updateSharePasswordIfNeeded($share, $originalShare); - if (empty($plainTextPassword) && $share->getSendPasswordByTalk()) { - throw new \InvalidArgumentException('Can’t enable sending the password by Talk with an empty password'); - } - if ($share->getExpirationDate() != $originalShare->getExpirationDate()) { //Verify the expiration date $this->validateExpirationDate($share); @@ -987,9 +981,11 @@ class Manager implements IManager { } } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { // The new password is not set again if it is the same as the old - // one. + // one, unless when switching from sending by Talk to sending by + // mail. $plainTextPassword = $share->getPassword(); - if (!empty($plainTextPassword) && !$this->updateSharePasswordIfNeeded($share, $originalShare)) { + if (!empty($plainTextPassword) && !$this->updateSharePasswordIfNeeded($share, $originalShare) && + !($originalShare->getSendPasswordByTalk() && !$share->getSendPasswordByTalk())) { $plainTextPassword = null; } if (empty($plainTextPassword) && !$originalShare->getSendPasswordByTalk() && $share->getSendPasswordByTalk()) { @@ -997,8 +993,6 @@ class Manager implements IManager { // would already have access to the share without having to call // the sharer to verify her identity throw new \InvalidArgumentException('Can’t enable sending the password by Talk without setting a new password'); - } elseif (empty($plainTextPassword) && $originalShare->getSendPasswordByTalk() && !$share->getSendPasswordByTalk()) { - throw new \InvalidArgumentException('Can’t disable sending the password by Talk without setting a new password'); } } @@ -1085,14 +1079,8 @@ class Manager implements IManager { * @return boolean whether the password was updated or not. */ private function updateSharePasswordIfNeeded(\OCP\Share\IShare $share, \OCP\Share\IShare $originalShare) { - $passwordsAreDifferent = ($share->getPassword() !== $originalShare->getPassword()) && - (($share->getPassword() !== null && $originalShare->getPassword() === null) || - ($share->getPassword() === null && $originalShare->getPassword() !== null) || - ($share->getPassword() !== null && $originalShare->getPassword() !== null && - !$this->hasher->verify($share->getPassword(), $originalShare->getPassword()))); - // Password updated. - if ($passwordsAreDifferent) { + if ($share->getPassword() !== $originalShare->getPassword()) { //Verify the password $this->verifyPassword($share->getPassword()); @@ -1102,10 +1090,6 @@ class Manager implements IManager { return true; } - } else { - // Reset the password to the original one, as it is either the same - // as the "new" password or a hashed version of it. - $share->setPassword($originalShare->getPassword()); } return false; |