diff options
author | Marcin Ćojewski <marcin.lojewski@mlojewski.me> | 2020-07-12 17:14:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-12 17:14:52 +0300 |
commit | fc49c8ade754c93d1a169efb11e2febdff109667 (patch) | |
tree | f76c4b2f1c73f7f200eecbae61a828675c10f35c | |
parent | 482c5c65c4470b56ac78133626187beec85ca34e (diff) | |
parent | a17a52ea4aefadb6a6c243262b4edafe2aaea7e7 (diff) |
Merge pull request #146 from nextcloud/feature/noid/use-new-dispatcher-for-password_policy
Use new dispatcher for password policy event
-rw-r--r-- | appinfo/info.xml | 2 | ||||
-rw-r--r-- | lib/Backend/UserBackend.php | 30 |
2 files changed, 15 insertions, 17 deletions
diff --git a/appinfo/info.xml b/appinfo/info.xml index 0c4c844..6d72844 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -22,7 +22,7 @@ <category>auth</category> <dependencies> <php min-version="7.1"/> - <nextcloud min-version="14" max-version="19"/> + <nextcloud min-version="18" max-version="19"/> </dependencies> <settings> <admin>\OCA\UserSQL\Settings\Admin</admin> diff --git a/lib/Backend/UserBackend.php b/lib/Backend/UserBackend.php index fca2959..c78bc0d 100644 --- a/lib/Backend/UserBackend.php +++ b/lib/Backend/UserBackend.php @@ -34,9 +34,11 @@ use OCA\UserSQL\Crypto\IPasswordAlgorithm; use OCA\UserSQL\Model\User; use OCA\UserSQL\Properties; use OCA\UserSQL\Repository\UserRepository; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\IL10N; use OCP\ILogger; +use OCP\Security\Events\ValidatePasswordPolicyEvent; use OCP\User\Backend\ABackend; use OCP\User\Backend\ICheckPasswordBackend; use OCP\User\Backend\ICountUsersBackend; @@ -46,8 +48,6 @@ use OCP\User\Backend\IPasswordConfirmationBackend; use OCP\User\Backend\IProvideAvatarBackend; use OCP\User\Backend\ISetDisplayNameBackend; use OCP\User\Backend\ISetPasswordBackend; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\EventDispatcher\GenericEvent; /** * The SQL user backend manager. @@ -93,7 +93,7 @@ final class UserBackend extends ABackend implements */ private $config; /** - * @var EventDispatcher The event dispatcher. + * @var IEventDispatcher The event dispatcher. */ private $eventDispatcher; /** @@ -104,19 +104,19 @@ final class UserBackend extends ABackend implements /** * The default constructor. * - * @param string $AppName The application name. - * @param Cache $cache The cache instance. - * @param ILogger $logger The logger instance. - * @param Properties $properties The properties array. - * @param UserRepository $userRepository The user repository. - * @param IL10N $localization The localization service. - * @param IConfig $config The config instance. - * @param EventDispatcher $eventDispatcher The event dispatcher. + * @param string $AppName The application name. + * @param Cache $cache The cache instance. + * @param ILogger $logger The logger instance. + * @param Properties $properties The properties array. + * @param UserRepository $userRepository The user repository. + * @param IL10N $localization The localization service. + * @param IConfig $config The config instance. + * @param IEventDispatcher $eventDispatcher The event dispatcher. */ public function __construct( $AppName, Cache $cache, ILogger $logger, Properties $properties, UserRepository $userRepository, IL10N $localization, IConfig $config, - EventDispatcher $eventDispatcher + IEventDispatcher $eventDispatcher ) { $this->appName = $AppName; $this->cache = $cache; @@ -515,10 +515,8 @@ final class UserBackend extends ABackend implements return false; } - $event = new GenericEvent($password); - $this->eventDispatcher->dispatch( - 'OCP\PasswordPolicy::validate', $event - ); + $event = new ValidatePasswordPolicyEvent($password); + $this->eventDispatcher->dispatchTyped($event); $user = $this->userRepository->findByUid($uid); if (!($user instanceof User)) { |