From 50badb3fb6b6a7fa51520ce380ece09b0a181179 Mon Sep 17 00:00:00 2001 From: Cyrille Bollu Date: Thu, 14 Apr 2022 21:08:53 +0200 Subject: Various improvements related to the recent implementation of temporary passwords for mail shares: 1- Changes style of "forgot password?" and "Back" button 2- Adds information about share password's expiration time in the emails sent. 3- Shows password expiration time in the Share menu 4- Fixes an issue when the message "Password expires..." would be shown for non email share types (which don't have temporary passswords) 5- At share's creation, password should only be sent when it's a permanent one See also https://github.com/nextcloud/server/issues/31952 Signed-off-by: Cyrille Bollu Signed-off-by: nextcloud-command --- apps/sharebymail/lib/ShareByMailProvider.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'apps/sharebymail/lib') diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index 1aa2307a27d..ccfebe0bded 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -198,7 +198,7 @@ class ShareByMailProvider implements IShareProvider { // Sends share password to receiver when it's a permanent one (otherwise she will have to request it via the showShare UI) // or to owner when the password shall be given during a Talk session - if ($this->config->getSystemValue('sharing.enable_mail_link_password_expiration', false) === true || $share->getSendPasswordByTalk()) { + if ($this->config->getSystemValue('sharing.enable_mail_link_password_expiration', false) === false || $share->getSendPasswordByTalk()) { $send = $this->sendPassword($share, $password); if ($passwordEnforced && $send === false) { $this->sendPasswordToOwner($share, $password); @@ -503,6 +503,13 @@ class ShareByMailProvider implements IShareProvider { $emailTemplate->addBodyText($this->l->t('It is protected with the following password:')); $emailTemplate->addBodyText($password); + if ($this->config->getSystemValue('sharing.enable_mail_link_password_expiration', false) === true) { + $expirationTime = new \DateTime(); + $expirationInterval = $this->config->getSystemValue('sharing.mail_link_password_expiration_interval', 3600); + $expirationTime = $expirationTime->add(new \DateInterval('PT' . $expirationInterval . 'S')); + $emailTemplate->addBodyText($this->l->t('This password will expire at %s', [$expirationTime->format('r')])); + } + // The "From" contains the sharers name $instanceName = $this->defaults->getName(); $senderName = $instanceName; @@ -627,7 +634,16 @@ class ShareByMailProvider implements IShareProvider { $emailTemplate->addBodyText($bodyPart); $emailTemplate->addBodyText($this->l->t('This is the password:')); $emailTemplate->addBodyText($password); + + if ($this->config->getSystemValue('sharing.enable_mail_link_password_expiration', false) === true) { + $expirationTime = new \DateTime(); + $expirationInterval = $this->config->getSystemValue('sharing.mail_link_password_expiration_interval', 3600); + $expirationTime = $expirationTime->add(new \DateInterval('PT' . $expirationInterval . 'S')); + $emailTemplate->addBodyText($this->l->t('This password will expire at %s', [$expirationTime->format('r')])); + } + $emailTemplate->addBodyText($this->l->t('You can choose a different password at any time in the share dialog.')); + $emailTemplate->addFooter(); $instanceName = $this->defaults->getName(); -- cgit v1.2.3