diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2020-07-09 23:04:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-09 23:04:38 +0300 |
commit | 56d412c027b65c5594db46ff680667172ceba0eb (patch) | |
tree | 0470672c8713dcceaec30be2a7cb40bb2609c56c | |
parent | 5ee566f9b56eddeb95240a5876cbc0a2ab9b2020 (diff) | |
parent | 5facd201115f18434e7bbf38fc2248dfd3b1f708 (diff) |
Merge pull request #144 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 | 16 |
2 files changed, 12 insertions, 6 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..095fda3 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; @@ -96,6 +98,10 @@ final class UserBackend extends ABackend implements * @var EventDispatcher The event dispatcher. */ private $eventDispatcher; + /** + * @var IEventDispatcher The new event dispatcher. + */ + private $newEventDispatcher; /** * @var IUserAction[] The actions to execute. */ @@ -112,11 +118,12 @@ final class UserBackend extends ABackend implements * @param IL10N $localization The localization service. * @param IConfig $config The config instance. * @param EventDispatcher $eventDispatcher The event dispatcher. + * @param IEventDispatcher $newEventDispatcher The new event dispatcher. */ public function __construct( $AppName, Cache $cache, ILogger $logger, Properties $properties, UserRepository $userRepository, IL10N $localization, IConfig $config, - EventDispatcher $eventDispatcher + EventDispatcher $eventDispatcher, IEventDispatcher $newEventDispatcher ) { $this->appName = $AppName; $this->cache = $cache; @@ -126,6 +133,7 @@ final class UserBackend extends ABackend implements $this->localization = $localization; $this->config = $config; $this->eventDispatcher = $eventDispatcher; + $this->newEventDispatcher = $newEventDispatcher; $this->actions = []; $this->initActions(); @@ -515,10 +523,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->newEventDispatcher->dispatchTyped($event); $user = $this->userRepository->findByUid($uid); if (!($user instanceof User)) { |