mirror of
https://github.com/nextcloud/server.git
synced 2024-09-02 05:55:17 +02:00
Merge pull request #37903 from nextcloud/fix/user_ldap-fix-multiple-ldap-support
Fix multiple LDAP configuration support by fixing AccessFactory
This commit is contained in:
commit
c995428431
@ -26,11 +26,11 @@ namespace OCA\User_LDAP;
|
||||
use OCA\User_LDAP\User\Manager;
|
||||
use OCP\IConfig;
|
||||
use OCP\IUserManager;
|
||||
use OCP\Server;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class AccessFactory {
|
||||
private ILDAPWrapper $ldap;
|
||||
private Manager $userManager;
|
||||
private Helper $helper;
|
||||
private IConfig $config;
|
||||
private IUserManager $ncUserManager;
|
||||
@ -38,13 +38,11 @@ class AccessFactory {
|
||||
|
||||
public function __construct(
|
||||
ILDAPWrapper $ldap,
|
||||
Manager $userManager,
|
||||
Helper $helper,
|
||||
IConfig $config,
|
||||
IUserManager $ncUserManager,
|
||||
LoggerInterface $logger) {
|
||||
$this->ldap = $ldap;
|
||||
$this->userManager = $userManager;
|
||||
$this->helper = $helper;
|
||||
$this->config = $config;
|
||||
$this->ncUserManager = $ncUserManager;
|
||||
@ -52,10 +50,11 @@ class AccessFactory {
|
||||
}
|
||||
|
||||
public function get(Connection $connection): Access {
|
||||
/* Each Access instance gets its own Manager instance, see OCA\User_LDAP\AppInfo\Application::register() */
|
||||
return new Access(
|
||||
$connection,
|
||||
$this->ldap,
|
||||
$this->userManager,
|
||||
Server::get(Manager::class),
|
||||
$this->helper,
|
||||
$this->config,
|
||||
$this->ncUserManager,
|
||||
|
@ -31,7 +31,6 @@ use OCA\User_LDAP\ConnectionFactory;
|
||||
use OCA\User_LDAP\Helper;
|
||||
use OCA\User_LDAP\LDAP;
|
||||
use OCA\User_LDAP\Mapping\UserMapping;
|
||||
use OCA\User_LDAP\User\Manager;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\TimedJob;
|
||||
use OCP\IAvatarManager;
|
||||
@ -48,8 +47,6 @@ class Sync extends TimedJob {
|
||||
protected $ldapHelper;
|
||||
/** @var LDAP */
|
||||
protected $ldap;
|
||||
/** @var Manager */
|
||||
protected $userManager;
|
||||
/** @var UserMapping */
|
||||
protected $mapper;
|
||||
/** @var IConfig */
|
||||
@ -69,9 +66,8 @@ class Sync extends TimedJob {
|
||||
/** @var AccessFactory */
|
||||
protected $accessFactory;
|
||||
|
||||
public function __construct(Manager $userManager, ITimeFactory $time) {
|
||||
public function __construct(ITimeFactory $time) {
|
||||
parent::__construct($time);
|
||||
$this->userManager = $userManager;
|
||||
$this->setInterval(
|
||||
(int)\OC::$server->getConfig()->getAppValue(
|
||||
'user_ldap',
|
||||
@ -350,10 +346,6 @@ class Sync extends TimedJob {
|
||||
$this->notificationManager = \OC::$server->getNotificationManager();
|
||||
}
|
||||
|
||||
if (isset($argument['userManager'])) {
|
||||
$this->userManager = $argument['userManager'];
|
||||
}
|
||||
|
||||
if (isset($argument['mapper'])) {
|
||||
$this->mapper = $argument['mapper'];
|
||||
} else {
|
||||
@ -369,14 +361,7 @@ class Sync extends TimedJob {
|
||||
if (isset($argument['accessFactory'])) {
|
||||
$this->accessFactory = $argument['accessFactory'];
|
||||
} else {
|
||||
$this->accessFactory = new AccessFactory(
|
||||
$this->ldap,
|
||||
$this->userManager,
|
||||
$this->ldapHelper,
|
||||
$this->config,
|
||||
$this->ncUserManager,
|
||||
$this->logger
|
||||
);
|
||||
$this->accessFactory = \OCP\Server::get(AccessFactory::class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,6 @@ use OCP\Notification\IManager;
|
||||
use Test\TestCase;
|
||||
|
||||
class SyncTest extends TestCase {
|
||||
|
||||
/** @var array */
|
||||
protected $arguments;
|
||||
/** @var Helper|\PHPUnit\Framework\MockObject\MockObject */
|
||||
@ -99,7 +98,7 @@ class SyncTest extends TestCase {
|
||||
'accessFactory' => $this->accessFactory,
|
||||
];
|
||||
|
||||
$this->sync = new Sync($this->userManager, $this->createMock(ITimeFactory::class));
|
||||
$this->sync = new Sync($this->createMock(ITimeFactory::class));
|
||||
}
|
||||
|
||||
public function intervalDataProvider() {
|
||||
|
Loading…
Reference in New Issue
Block a user