summaryrefslogtreecommitdiffstats
path: root/apps/sharebymail/lib/ShareByMailProvider.php
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2020-05-28 20:27:33 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2020-05-28 21:51:22 +0200
commite59e283cc2f47753e76529a42dcbb491da0fb799 (patch)
tree1379c970481f10e79b34b8796cb27222e6e399d9 /apps/sharebymail/lib/ShareByMailProvider.php
parenta2b0a7c30e128f46f38a5b0930859fd9c4603f6b (diff)
downloadnextcloud-server-e59e283cc2f47753e76529a42dcbb491da0fb799.tar.gz
nextcloud-server-e59e283cc2f47753e76529a42dcbb491da0fb799.zip
Fix creating a mail share with a password
When a mail share was created with a password the given password was not hashed, so it was not possible to open the share with that password. Moreover, if passwords were enforced the given password was ignored and a new one was set (although in this case it was hashed so it worked as expected). Now the given password is properly hashed and not overriden. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/sharebymail/lib/ShareByMailProvider.php')
-rw-r--r--apps/sharebymail/lib/ShareByMailProvider.php10
1 files changed, 6 insertions, 4 deletions
diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php
index 4292ac9bf18..3a1a069172c 100644
--- a/apps/sharebymail/lib/ShareByMailProvider.php
+++ b/apps/sharebymail/lib/ShareByMailProvider.php
@@ -187,12 +187,16 @@ class ShareByMailProvider implements IShareProvider {
// if the admin enforces a password for all mail shares we create a
// random password and send it to the recipient
- $password = '';
+ $password = $share->getPassword() ?: '';
$passwordEnforced = $this->settingsManager->enforcePasswordProtection();
- if ($passwordEnforced) {
+ if ($passwordEnforced && empty($password)) {
$password = $this->autoGeneratePassword($share);
}
+ if (!empty($password)) {
+ $share->setPassword($this->hasher->hash($password));
+ }
+
$shareId = $this->createMailShare($share);
$send = $this->sendPassword($share, $password);
if ($passwordEnforced && $send === false) {
@@ -233,8 +237,6 @@ class ShareByMailProvider implements IShareProvider {
$password = $this->secureRandom->generate($passwordLength, $passwordCharset);
- $share->setPassword($this->hasher->hash($password));
-
return $password;
}