Fix empty password check for mail shares
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
This commit is contained in:
parent
9b86f5f674
commit
4b5a05cfee
|
@ -1000,7 +1000,8 @@ class Manager implements IManager {
|
||||||
// The new password is not set again if it is the same as the old
|
// The new password is not set again if it is the same as the old
|
||||||
// one.
|
// one.
|
||||||
$plainTextPassword = $share->getPassword();
|
$plainTextPassword = $share->getPassword();
|
||||||
if (!empty($plainTextPassword) && !$this->updateSharePasswordIfNeeded($share, $originalShare)) {
|
$updatedPassword = $this->updateSharePasswordIfNeeded($share, $originalShare);
|
||||||
|
if (!empty($plainTextPassword) && !$updatedPassword) {
|
||||||
$plainTextPassword = null;
|
$plainTextPassword = null;
|
||||||
}
|
}
|
||||||
if (empty($plainTextPassword) && !$originalShare->getSendPasswordByTalk() && $share->getSendPasswordByTalk()) {
|
if (empty($plainTextPassword) && !$originalShare->getSendPasswordByTalk() && $share->getSendPasswordByTalk()) {
|
||||||
|
@ -1108,9 +1109,13 @@ class Manager implements IManager {
|
||||||
$this->verifyPassword($share->getPassword());
|
$this->verifyPassword($share->getPassword());
|
||||||
|
|
||||||
// If a password is set. Hash it!
|
// If a password is set. Hash it!
|
||||||
if ($share->getPassword() !== null) {
|
if (!empty($share->getPassword())) {
|
||||||
$share->setPassword($this->hasher->hash($share->getPassword()));
|
$share->setPassword($this->hasher->hash($share->getPassword()));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// Empty string and null are seen as NOT password protected
|
||||||
|
$share->setPassword(null);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3499,7 +3499,7 @@ class ManagerTest extends \Test\TestCase {
|
||||||
$manager->expects($this->once())->method('canShare')->willReturn(true);
|
$manager->expects($this->once())->method('canShare')->willReturn(true);
|
||||||
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
|
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
|
||||||
$manager->expects($this->once())->method('generalCreateChecks')->with($share);
|
$manager->expects($this->once())->method('generalCreateChecks')->with($share);
|
||||||
$manager->expects($this->never())->method('verifyPassword');
|
$manager->expects($this->once())->method('verifyPassword');
|
||||||
$manager->expects($this->never())->method('pathCreateChecks');
|
$manager->expects($this->never())->method('pathCreateChecks');
|
||||||
$manager->expects($this->never())->method('linkCreateChecks');
|
$manager->expects($this->never())->method('linkCreateChecks');
|
||||||
$manager->expects($this->never())->method('validateExpirationDateLink');
|
$manager->expects($this->never())->method('validateExpirationDateLink');
|
||||||
|
@ -3571,7 +3571,7 @@ class ManagerTest extends \Test\TestCase {
|
||||||
$manager->expects($this->once())->method('canShare')->willReturn(true);
|
$manager->expects($this->once())->method('canShare')->willReturn(true);
|
||||||
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
|
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
|
||||||
$manager->expects($this->once())->method('generalCreateChecks')->with($share);
|
$manager->expects($this->once())->method('generalCreateChecks')->with($share);
|
||||||
$manager->expects($this->never())->method('verifyPassword');
|
$manager->expects($this->once())->method('verifyPassword');
|
||||||
$manager->expects($this->never())->method('pathCreateChecks');
|
$manager->expects($this->never())->method('pathCreateChecks');
|
||||||
$manager->expects($this->never())->method('linkCreateChecks');
|
$manager->expects($this->never())->method('linkCreateChecks');
|
||||||
$manager->expects($this->never())->method('validateExpirationDateLink');
|
$manager->expects($this->never())->method('validateExpirationDateLink');
|
||||||
|
|
Loading…
Reference in New Issue