diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-11-19 21:18:00 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-11-27 11:56:12 +0300 |
commit | 1a886b1472cad1fb04e8073d2749514e2d97a506 (patch) | |
tree | a66f332dcf0b2a9123f40b36dc0532103b8e9461 /lib/private | |
parent | a2046db6d011bef399f7952b2daf18734d6290ad (diff) |
Add typed events for password_policy
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Share20/Manager.php | 4 | ||||
-rw-r--r-- | lib/private/User/Database.php | 15 |
2 files changed, 9 insertions, 10 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index d9809fd128a..210dc7772c0 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -55,6 +55,7 @@ use OCP\IUser; use OCP\IUserManager; use OCP\L10N\IFactory; use OCP\Mail\IMailer; +use OCP\Security\Events\ValidatePasswordPolicyEvent; use OCP\Security\IHasher; use OCP\Security\ISecureRandom; use OCP\Share; @@ -191,8 +192,7 @@ class Manager implements IManager { // Let others verify the password try { - $event = new GenericEvent($password); - $this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event); + $this->eventDispatcher->dispatch(new ValidatePasswordPolicyEvent($password)); } catch (HintException $e) { throw new \Exception($e->getHint()); } diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php index 23dbe8c2334..a4c35deb2b8 100644 --- a/lib/private/User/Database.php +++ b/lib/private/User/Database.php @@ -58,7 +58,9 @@ declare(strict_types=1); namespace OC\User; use OC\Cache\CappedMemoryCache; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IDBConnection; +use OCP\Security\Events\ValidatePasswordPolicyEvent; use OCP\User\Backend\ABackend; use OCP\User\Backend\ICheckPasswordBackend; use OCP\User\Backend\ICountUsersBackend; @@ -68,7 +70,6 @@ use OCP\User\Backend\IGetHomeBackend; use OCP\User\Backend\IGetRealUIDBackend; use OCP\User\Backend\ISetDisplayNameBackend; use OCP\User\Backend\ISetPasswordBackend; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; /** @@ -86,7 +87,7 @@ class Database extends ABackend /** @var CappedMemoryCache */ private $cache; - /** @var EventDispatcherInterface */ + /** @var IEventDispatcher */ private $eventDispatcher; /** @var IDBConnection */ @@ -98,13 +99,13 @@ class Database extends ABackend /** * \OC\User\Database constructor. * - * @param EventDispatcherInterface $eventDispatcher + * @param IEventDispatcher $eventDispatcher * @param string $table */ public function __construct($eventDispatcher = null, $table = 'users') { $this->cache = new CappedMemoryCache(); $this->table = $table; - $this->eventDispatcher = $eventDispatcher ? $eventDispatcher : \OC::$server->getEventDispatcher(); + $this->eventDispatcher = $eventDispatcher ? $eventDispatcher : \OC::$server->query(IEventDispatcher::class); } /** @@ -130,8 +131,7 @@ class Database extends ABackend $this->fixDI(); if (!$this->userExists($uid)) { - $event = new GenericEvent($password); - $this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event); + $this->eventDispatcher->dispatchTyped(new ValidatePasswordPolicyEvent($password)); $qb = $this->dbConn->getQueryBuilder(); $qb->insert($this->table) @@ -199,8 +199,7 @@ class Database extends ABackend $this->fixDI(); if ($this->userExists($uid)) { - $event = new GenericEvent($password); - $this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event); + $this->eventDispatcher->dispatchTyped(new ValidatePasswordPolicyEvent($password)); $hasher = \OC::$server->getHasher(); $hashedPassword = $hasher->hash($password); |