Merge pull request #22057 from owncloud/share2_update_hash
Update old password hashed for link shares on access
This commit is contained in:
commit
eee6f3d406
2 changed files with 24 additions and 1 deletions
|
@ -815,7 +815,9 @@ class Manager implements IManager {
|
|||
}
|
||||
|
||||
if (!empty($newHash)) {
|
||||
//TODO update hash!
|
||||
$share->setPassword($newHash);
|
||||
$provider = $this->factory->getProviderForType($share->getShareType());
|
||||
$provider->update($share);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1645,6 +1645,27 @@ class ManagerTest extends \Test\TestCase {
|
|||
$this->assertTrue($this->manager->checkPassword($share, 'password'));
|
||||
}
|
||||
|
||||
public function testCheckPasswordUpdateShare() {
|
||||
$share = $this->manager->newShare();
|
||||
$share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
||||
->setPassword('passwordHash');
|
||||
|
||||
$this->hasher->method('verify')->with('password', 'passwordHash', '')
|
||||
->will($this->returnCallback(function($pass, $hash, &$newHash) {
|
||||
$newHash = 'newHash';
|
||||
|
||||
return true;
|
||||
}));
|
||||
|
||||
$this->defaultProvider->expects($this->once())
|
||||
->method('update')
|
||||
->with($this->callback(function (\OCP\Share\IShare $share) {
|
||||
return $share->getPassword() === 'newHash';
|
||||
}));
|
||||
|
||||
$this->assertTrue($this->manager->checkPassword($share, 'password'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The Share API is disabled
|
||||
|
|
Loading…
Reference in a new issue