Skip to content

Commit 08ac663

Browse files
committed
Use new dispatcher for password policy event
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
1 parent 482c5c6 commit 08ac663

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

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: 7 additions & 9 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
/**
@@ -111,12 +111,12 @@ final class UserBackend extends ABackend implements
111111
* @param UserRepository $userRepository The user repository.
112112
* @param IL10N $localization The localization service.
113113
* @param IConfig $config The config instance.
114-
* @param EventDispatcher $eventDispatcher The event dispatcher.
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)