summaryrefslogtreecommitdiffstats
path: root/lib/private/Share20/Manager.php
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2020-05-28 20:37:18 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2020-05-28 21:51:28 +0200
commita426f84dbe20c02f81cfec70a5a5bd73950a70b3 (patch)
tree6d489c0bccc0bf8d83d8263d1a8c1fa56d5c52fc /lib/private/Share20/Manager.php
parent7569590514637725e044e0986be249e7b9f5b940 (diff)
downloadnextcloud-server-a426f84dbe20c02f81cfec70a5a5bd73950a70b3.tar.gz
nextcloud-server-a426f84dbe20c02f81cfec70a5a5bd73950a70b3.zip
Fix enabling send password by Talk with same password in mail shares
When "send password by Talk" is enabled in a mail share a new password must be also set. However, when the passwords of the original and the new share were compared it was not taken into account that the original password is now hashed, while the new one is not (unless no new password was sent, in which case the password of the original share was set in the new share by the controller, but that was already prevented due to both passwords being literally the same), so it was possible to set the same password again. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'lib/private/Share20/Manager.php')
-rw-r--r--lib/private/Share20/Manager.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 4f35ec0f7fd..2850cba7e45 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -1081,8 +1081,14 @@ 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 ($share->getPassword() !== $originalShare->getPassword()) {
+ if ($passwordsAreDifferent) {
//Verify the password
$this->verifyPassword($share->getPassword());
@@ -1092,6 +1098,10 @@ 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;