summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-07-10 12:36:28 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-07-24 13:56:29 +0200
commitd582a66bea10e3a7ab41c1e475c5eec3eb218ba0 (patch)
tree3c158f04625e7661728623b95a94ae6b221ca7c9 /lib
parentdd0c5e297e3190b1f4324fb2e88e08760d8d71b8 (diff)
downloadnextcloud-server-d582a66bea10e3a7ab41c1e475c5eec3eb218ba0.tar.gz
nextcloud-server-d582a66bea10e3a7ab41c1e475c5eec3eb218ba0.zip
Honour "sendPasswordByTalk" property in mail shares
When a password was set for a mail share an e-mail was sent to the recipient with the password. Now the e-mail is no longer sent if the password is meant to be sent by Talk. However, before the e-mail was not sent when the share was updated but the password was not changed. Now an e-mail is sent in that case too if switching from a password sent by Talk to a password sent by mail. On the other hand, when switching from a password sent by mail to a password sent by Talk it is mandatory to change the password; otherwise the recipient would already have access to the share without having to call the sharer to verify her identity. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'lib')
-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 76b523afd10..d0316b44c1a 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -827,10 +827,20 @@ class Manager implements IManager {
$expirationDateUpdated = true;
}
} 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, unless when switching from sending by Talk to sending by
+ // mail.
$plainTextPassword = $share->getPassword();
- if (!$this->updateSharePasswordIfNeeded($share, $originalShare)) {
+ if (!empty($plainTextPassword) && !$this->updateSharePasswordIfNeeded($share, $originalShare) &&
+ !($originalShare->getSendPasswordByTalk() && !$share->getSendPasswordByTalk())) {
$plainTextPassword = null;
}
+ if (empty($plainTextPassword) && !$originalShare->getSendPasswordByTalk() && $share->getSendPasswordByTalk()) {
+ // If the same password was already sent by mail the recipient
+ // 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');
+ }
}
$this->pathCreateChecks($share->getNode());