diff --git a/CHANGELOG.md b/CHANGELOG.md index dc488c6..b8c4686 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] ### Added - Users can confirm passwords +- Support Nextcloud password_policy ### Fixed - Getting user display names backend diff --git a/lib/Backend/UserBackend.php b/lib/Backend/UserBackend.php index fb77f6a..1891f45 100644 --- a/lib/Backend/UserBackend.php +++ b/lib/Backend/UserBackend.php @@ -45,6 +45,8 @@ 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. @@ -89,6 +91,10 @@ final class UserBackend extends ABackend implements * @var IConfig The config instance. */ private $config; + /** + * @var EventDispatcher The event dispatcher. + */ + private $eventDispatcher; /** * @var IUserAction[] The actions to execute. */ @@ -97,17 +103,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 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. */ public function __construct( $AppName, Cache $cache, ILogger $logger, Properties $properties, - UserRepository $userRepository, IL10N $localization, IConfig $config + UserRepository $userRepository, IL10N $localization, IConfig $config, + EventDispatcher $eventDispatcher ) { $this->appName = $AppName; $this->cache = $cache; @@ -116,6 +124,7 @@ final class UserBackend extends ABackend implements $this->userRepository = $userRepository; $this->localization = $localization; $this->config = $config; + $this->eventDispatcher = $eventDispatcher; $this->actions = []; $this->initActions(); @@ -492,6 +501,11 @@ final class UserBackend extends ABackend implements return false; } + $event = new GenericEvent($password); + $this->eventDispatcher->dispatch( + 'OCP\PasswordPolicy::validate', $event + ); + $user = $this->userRepository->findByUid($uid); if (!($user instanceof User)) { return false;