]> source.dussan.org Git - nextcloud-server.git/commitdiff
Update old password hashed for link shares on access
authorRoeland Jago Douma <rullzer@owncloud.com>
Mon, 1 Feb 2016 20:46:32 +0000 (21:46 +0100)
committerRoeland Jago Douma <rullzer@owncloud.com>
Mon, 1 Feb 2016 20:46:32 +0000 (21:46 +0100)
Fixes https://github.com/owncloud/core/issues/16594

lib/private/share20/manager.php
tests/lib/share20/managertest.php

index e45fa4b40f9368965827ff2c2eeebd5ddb7520f0..581e62fbd7e51a9d343dd39ac042eb54f77b08a1 100644 (file)
@@ -819,7 +819,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;
index b5559bb51728e9be7fe4eb6fffa352e0c49b1505..cdcb71ed1e57d5b224e70fc56f7947bdd25d2433 100644 (file)
@@ -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