Skip to content

Commit fc49c8a

Browse files
authored
Merge pull request #146 from nextcloud/feature/noid/use-new-dispatcher-for-password_policy
Use new dispatcher for password policy event
2 parents 482c5c6 + a17a52e commit fc49c8a

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<category>auth</category>
2323
<dependencies>
2424
<php min-version="7.1"/>
25-
<nextcloud min-version="14" max-version="19"/>
25+
<nextcloud min-version="18" max-version="19"/>
2626
</dependencies>
2727
<settings>
2828
<admin>\OCA\UserSQL\Settings\Admin</admin>

lib/Backend/UserBackend.php

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@
3434
use OCA\UserSQL\Model\User;
3535
use OCA\UserSQL\Properties;
3636
use OCA\UserSQL\Repository\UserRepository;
37+
use OCP\EventDispatcher\IEventDispatcher;
3738
use OCP\IConfig;
3839
use OCP\IL10N;
3940
use OCP\ILogger;
41+
use OCP\Security\Events\ValidatePasswordPolicyEvent;
4042
use OCP\User\Backend\ABackend;
4143
use OCP\User\Backend\ICheckPasswordBackend;
4244
use OCP\User\Backend\ICountUsersBackend;
@@ -46,8 +48,6 @@
4648
use OCP\User\Backend\IProvideAvatarBackend;
4749
use OCP\User\Backend\ISetDisplayNameBackend;
4850
use OCP\User\Backend\ISetPasswordBackend;
49-
use Symfony\Component\EventDispatcher\EventDispatcher;
50-
use Symfony\Component\EventDispatcher\GenericEvent;
5151

5252
/**
5353
* The SQL user backend manager.
@@ -93,7 +93,7 @@ final class UserBackend extends ABackend implements
9393
*/
9494
private $config;
9595
/**
96-
* @var EventDispatcher The event dispatcher.
96+
* @var IEventDispatcher The event dispatcher.
9797
*/
9898
private $eventDispatcher;
9999
/**
@@ -104,19 +104,19 @@ final class UserBackend extends ABackend implements
104104
/**
105105
* The default constructor.
106106
*
107-
* @param string $AppName The application name.
108-
* @param Cache $cache The cache instance.
109-
* @param ILogger $logger The logger instance.
110-
* @param Properties $properties The properties array.
111-
* @param UserRepository $userRepository The user repository.
112-
* @param IL10N $localization The localization service.
113-
* @param IConfig $config The config instance.
114-
* @param EventDispatcher $eventDispatcher The event dispatcher.
107+
* @param string $AppName The application name.
108+
* @param Cache $cache The cache instance.
109+
* @param ILogger $logger The logger instance.
110+
* @param Properties $properties The properties array.
111+
* @param UserRepository $userRepository The user repository.
112+
* @param IL10N $localization The localization service.
113+
* @param IConfig $config The config instance.
114+
* @param IEventDispatcher $eventDispatcher The event dispatcher.
115115
*/
116116
public function __construct(
117117
$AppName, Cache $cache, ILogger $logger, Properties $properties,
118118
UserRepository $userRepository, IL10N $localization, IConfig $config,
119-
EventDispatcher $eventDispatcher
119+
IEventDispatcher $eventDispatcher
120120
) {
121121
$this->appName = $AppName;
122122
$this->cache = $cache;
@@ -515,10 +515,8 @@ public function setPassword(string $uid, string $password): bool
515515
return false;
516516
}
517517

518-
$event = new GenericEvent($password);
519-
$this->eventDispatcher->dispatch(
520-
'OCP\PasswordPolicy::validate', $event
521-
);
518+
$event = new ValidatePasswordPolicyEvent($password);
519+
$this->eventDispatcher->dispatchTyped($event);
522520

523521
$user = $this->userRepository->findByUid($uid);
524522
if (!($user instanceof User)) {

0 commit comments

Comments
 (0)