summaryrefslogtreecommitdiffstats
path: root/lib/private/User/Database.php
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2019-11-19 19:18:00 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2019-11-27 09:56:12 +0100
commit1a886b1472cad1fb04e8073d2749514e2d97a506 (patch)
treea66f332dcf0b2a9123f40b36dc0532103b8e9461 /lib/private/User/Database.php
parenta2046db6d011bef399f7952b2daf18734d6290ad (diff)
downloadnextcloud-server-1a886b1472cad1fb04e8073d2749514e2d97a506.tar.gz
nextcloud-server-1a886b1472cad1fb04e8073d2749514e2d97a506.zip
Add typed events for password_policy
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/private/User/Database.php')
-rw-r--r--lib/private/User/Database.php15
1 files changed, 7 insertions, 8 deletions
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);