diff options
author | Marcin Łojewski <marcin.lojewski@mlojewski.me> | 2019-02-17 20:51:26 +0300 |
---|---|---|
committer | Marcin Łojewski <marcin.lojewski@mlojewski.me> | 2019-02-17 20:51:26 +0300 |
commit | f94def108b0cb79afb9f96ab515c22069d3f508f (patch) | |
tree | 1fed363f4e9926e192ae2d16f195d3602c59437a | |
parent | a2ca6eb57935b1d2589ab30bc72d1cd63d6c8910 (diff) |
issue#100 Support Nextcloud password_policy
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | lib/Backend/UserBackend.php | 30 |
2 files changed, 23 insertions, 8 deletions
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. @@ -90,6 +92,10 @@ final class UserBackend extends ABackend implements */ private $config; /** + * @var EventDispatcher The event dispatcher. + */ + private $eventDispatcher; + /** * @var IUserAction[] The actions to execute. */ private $actions; @@ -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; |