issue#100 Support Nextcloud password_policy

This commit is contained in:
Marcin Łojewski
2019-02-17 18:51:26 +01:00
parent a2ca6eb579
commit f94def108b
2 changed files with 23 additions and 8 deletions

View File

@@ -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

View File

@@ -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;