summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-07-24 17:06:56 +0200
committerGitHub <noreply@github.com>2018-07-24 17:06:56 +0200
commit9b9d729acf8a6c46374d1ef55915c6fca988b191 (patch)
treea38045f49139774bafcc37b458ec711dcd2af796 /lib/private
parent7da815bb0403ebb072866b61779a84835b9a74b8 (diff)
parent911093549ebe3068dc7df918c552dc45a4ed43f5 (diff)
downloadnextcloud-server-9b9d729acf8a6c46374d1ef55915c6fca988b191.tar.gz
nextcloud-server-9b9d729acf8a6c46374d1ef55915c6fca988b191.zip
Merge pull request #10238 from nextcloud/add-support-for-sending-the-password-for-a-share-by-nextcloud-talk
Add support for sending the password for a share by Nextcloud Talk
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Share20/Manager.php12
-rw-r--r--lib/private/Share20/Share.php17
2 files changed, 28 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());
diff --git a/lib/private/Share20/Share.php b/lib/private/Share20/Share.php
index e54497c9b55..71c0453d9e5 100644
--- a/lib/private/Share20/Share.php
+++ b/lib/private/Share20/Share.php
@@ -63,6 +63,8 @@ class Share implements \OCP\Share\IShare {
private $expireDate;
/** @var string */
private $password;
+ /** @var bool */
+ private $sendPasswordByTalk = false;
/** @var string */
private $token;
/** @var int */
@@ -405,6 +407,21 @@ class Share implements \OCP\Share\IShare {
/**
* @inheritdoc
*/
+ public function setSendPasswordByTalk(bool $sendPasswordByTalk) {
+ $this->sendPasswordByTalk = $sendPasswordByTalk;
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getSendPasswordByTalk(): bool {
+ return $this->sendPasswordByTalk;
+ }
+
+ /**
+ * @inheritdoc
+ */
public function setToken($token) {
$this->token = $token;
return $this;