check password for link shares
This commit is contained in:
parent
db6361ef03
commit
630e4b1b46
|
@ -674,7 +674,8 @@ class Server extends ServerContainer implements IServerContainer {
|
||||||
$c->getL10N('core'),
|
$c->getL10N('core'),
|
||||||
$factory,
|
$factory,
|
||||||
$c->getUserManager(),
|
$c->getUserManager(),
|
||||||
$c->getLazyRootFolder()
|
$c->getLazyRootFolder(),
|
||||||
|
$c->getEventDispatcher()
|
||||||
);
|
);
|
||||||
|
|
||||||
return $manager;
|
return $manager;
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace OC\Share20;
|
||||||
|
|
||||||
use OC\Cache\CappedMemoryCache;
|
use OC\Cache\CappedMemoryCache;
|
||||||
use OC\Files\Mount\MoveableMount;
|
use OC\Files\Mount\MoveableMount;
|
||||||
|
use OC\HintException;
|
||||||
use OCP\Files\File;
|
use OCP\Files\File;
|
||||||
use OCP\Files\Folder;
|
use OCP\Files\Folder;
|
||||||
use OCP\Files\IRootFolder;
|
use OCP\Files\IRootFolder;
|
||||||
|
@ -42,6 +43,8 @@ use OCP\Share\Exceptions\GenericShareException;
|
||||||
use OCP\Share\Exceptions\ShareNotFound;
|
use OCP\Share\Exceptions\ShareNotFound;
|
||||||
use OCP\Share\IManager;
|
use OCP\Share\IManager;
|
||||||
use OCP\Share\IProviderFactory;
|
use OCP\Share\IProviderFactory;
|
||||||
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
|
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is the communication hub for all sharing related operations.
|
* This class is the communication hub for all sharing related operations.
|
||||||
|
@ -70,6 +73,8 @@ class Manager implements IManager {
|
||||||
private $rootFolder;
|
private $rootFolder;
|
||||||
/** @var CappedMemoryCache */
|
/** @var CappedMemoryCache */
|
||||||
private $sharingDisabledForUsersCache;
|
private $sharingDisabledForUsersCache;
|
||||||
|
/** @var EventDispatcher */
|
||||||
|
private $eventDispatcher;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -85,6 +90,7 @@ class Manager implements IManager {
|
||||||
* @param IProviderFactory $factory
|
* @param IProviderFactory $factory
|
||||||
* @param IUserManager $userManager
|
* @param IUserManager $userManager
|
||||||
* @param IRootFolder $rootFolder
|
* @param IRootFolder $rootFolder
|
||||||
|
* @param EventDispatcher $eventDispatcher
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ILogger $logger,
|
ILogger $logger,
|
||||||
|
@ -96,7 +102,8 @@ class Manager implements IManager {
|
||||||
IL10N $l,
|
IL10N $l,
|
||||||
IProviderFactory $factory,
|
IProviderFactory $factory,
|
||||||
IUserManager $userManager,
|
IUserManager $userManager,
|
||||||
IRootFolder $rootFolder
|
IRootFolder $rootFolder,
|
||||||
|
EventDispatcher $eventDispatcher
|
||||||
) {
|
) {
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
@ -108,6 +115,7 @@ class Manager implements IManager {
|
||||||
$this->factory = $factory;
|
$this->factory = $factory;
|
||||||
$this->userManager = $userManager;
|
$this->userManager = $userManager;
|
||||||
$this->rootFolder = $rootFolder;
|
$this->rootFolder = $rootFolder;
|
||||||
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
$this->sharingDisabledForUsersCache = new CappedMemoryCache();
|
$this->sharingDisabledForUsersCache = new CappedMemoryCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,6 +145,13 @@ class Manager implements IManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$event = new GenericEvent($password);
|
||||||
|
$this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event);
|
||||||
|
} catch (HintException $e) {
|
||||||
|
throw new \Exception($e->getHint());
|
||||||
|
}
|
||||||
|
|
||||||
// Let others verify the password
|
// Let others verify the password
|
||||||
$accepted = true;
|
$accepted = true;
|
||||||
$message = '';
|
$message = '';
|
||||||
|
|
|
@ -37,6 +37,7 @@ use OCP\Security\ISecureRandom;
|
||||||
use OCP\Security\IHasher;
|
use OCP\Security\IHasher;
|
||||||
use OCP\Files\Mount\IMountManager;
|
use OCP\Files\Mount\IMountManager;
|
||||||
use OCP\IGroupManager;
|
use OCP\IGroupManager;
|
||||||
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ManagerTest
|
* Class ManagerTest
|
||||||
|
@ -70,6 +71,8 @@ class ManagerTest extends \Test\TestCase {
|
||||||
protected $userManager;
|
protected $userManager;
|
||||||
/** @var IRootFolder | \PHPUnit_Framework_MockObject_MockObject */
|
/** @var IRootFolder | \PHPUnit_Framework_MockObject_MockObject */
|
||||||
protected $rootFolder;
|
protected $rootFolder;
|
||||||
|
/** @var EventDispatcher | \PHPUnit_Framework_MockObject_MockObject */
|
||||||
|
protected $eventDispatcher;
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
|
||||||
|
@ -81,6 +84,7 @@ class ManagerTest extends \Test\TestCase {
|
||||||
$this->groupManager = $this->getMock('\OCP\IGroupManager');
|
$this->groupManager = $this->getMock('\OCP\IGroupManager');
|
||||||
$this->userManager = $this->getMock('\OCP\IUserManager');
|
$this->userManager = $this->getMock('\OCP\IUserManager');
|
||||||
$this->rootFolder = $this->getMock('\OCP\Files\IRootFolder');
|
$this->rootFolder = $this->getMock('\OCP\Files\IRootFolder');
|
||||||
|
$this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcher');
|
||||||
|
|
||||||
$this->l = $this->getMock('\OCP\IL10N');
|
$this->l = $this->getMock('\OCP\IL10N');
|
||||||
$this->l->method('t')
|
$this->l->method('t')
|
||||||
|
@ -100,7 +104,8 @@ class ManagerTest extends \Test\TestCase {
|
||||||
$this->l,
|
$this->l,
|
||||||
$this->factory,
|
$this->factory,
|
||||||
$this->userManager,
|
$this->userManager,
|
||||||
$this->rootFolder
|
$this->rootFolder,
|
||||||
|
$this->eventDispatcher
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->defaultProvider = $this->getMockBuilder('\OC\Share20\DefaultShareProvider')
|
$this->defaultProvider = $this->getMockBuilder('\OC\Share20\DefaultShareProvider')
|
||||||
|
@ -127,7 +132,8 @@ class ManagerTest extends \Test\TestCase {
|
||||||
$this->l,
|
$this->l,
|
||||||
$this->factory,
|
$this->factory,
|
||||||
$this->userManager,
|
$this->userManager,
|
||||||
$this->rootFolder
|
$this->rootFolder,
|
||||||
|
$this->eventDispatcher
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2022,7 +2028,8 @@ class ManagerTest extends \Test\TestCase {
|
||||||
$this->l,
|
$this->l,
|
||||||
$factory,
|
$factory,
|
||||||
$this->userManager,
|
$this->userManager,
|
||||||
$this->rootFolder
|
$this->rootFolder,
|
||||||
|
$this->eventDispatcher
|
||||||
);
|
);
|
||||||
|
|
||||||
$share = $this->getMock('\OCP\Share\IShare');
|
$share = $this->getMock('\OCP\Share\IShare');
|
||||||
|
@ -2054,7 +2061,8 @@ class ManagerTest extends \Test\TestCase {
|
||||||
$this->l,
|
$this->l,
|
||||||
$factory,
|
$factory,
|
||||||
$this->userManager,
|
$this->userManager,
|
||||||
$this->rootFolder
|
$this->rootFolder,
|
||||||
|
$this->eventDispatcher
|
||||||
);
|
);
|
||||||
|
|
||||||
$share = $this->getMock('\OCP\Share\IShare');
|
$share = $this->getMock('\OCP\Share\IShare');
|
||||||
|
|
Loading…
Reference in New Issue