diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2016-06-24 17:53:37 +0200 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2016-06-27 14:05:27 +0200 |
commit | 630e4b1b463c773e4a23556672fbd90af6176cab (patch) | |
tree | 08139374a319fc18b60c6557e0fbfe84dcb46bfc /lib/private | |
parent | db6361ef0314868edc9d58a81c0806c8c758af0a (diff) | |
download | nextcloud-server-630e4b1b463c773e4a23556672fbd90af6176cab.tar.gz nextcloud-server-630e4b1b463c773e4a23556672fbd90af6176cab.zip |
check password for link shares
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Server.php | 5 | ||||
-rw-r--r-- | lib/private/Share20/Manager.php | 17 |
2 files changed, 19 insertions, 3 deletions
diff --git a/lib/private/Server.php b/lib/private/Server.php index 8345a0b66e0..ab2e7b1fdf6 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -235,7 +235,7 @@ class Server extends ServerContainer implements IServerContainer { } else { $defaultTokenProvider = null; } - + $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig()); $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); @@ -674,7 +674,8 @@ class Server extends ServerContainer implements IServerContainer { $c->getL10N('core'), $factory, $c->getUserManager(), - $c->getLazyRootFolder() + $c->getLazyRootFolder(), + $c->getEventDispatcher() ); return $manager; diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 2857a394e1e..b337c3c7108 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -26,6 +26,7 @@ namespace OC\Share20; use OC\Cache\CappedMemoryCache; use OC\Files\Mount\MoveableMount; +use OC\HintException; use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IRootFolder; @@ -42,6 +43,8 @@ use OCP\Share\Exceptions\GenericShareException; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; 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. @@ -70,6 +73,8 @@ class Manager implements IManager { private $rootFolder; /** @var CappedMemoryCache */ private $sharingDisabledForUsersCache; + /** @var EventDispatcher */ + private $eventDispatcher; /** @@ -85,6 +90,7 @@ class Manager implements IManager { * @param IProviderFactory $factory * @param IUserManager $userManager * @param IRootFolder $rootFolder + * @param EventDispatcher $eventDispatcher */ public function __construct( ILogger $logger, @@ -96,7 +102,8 @@ class Manager implements IManager { IL10N $l, IProviderFactory $factory, IUserManager $userManager, - IRootFolder $rootFolder + IRootFolder $rootFolder, + EventDispatcher $eventDispatcher ) { $this->logger = $logger; $this->config = $config; @@ -108,6 +115,7 @@ class Manager implements IManager { $this->factory = $factory; $this->userManager = $userManager; $this->rootFolder = $rootFolder; + $this->eventDispatcher = $eventDispatcher; $this->sharingDisabledForUsersCache = new CappedMemoryCache(); } @@ -137,6 +145,13 @@ class Manager implements IManager { 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 $accepted = true; $message = ''; |