diff options
author | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2023-05-02 17:11:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-02 17:11:01 +0200 |
commit | c995428431c5b1a6b593cd960d63a25d027b9039 (patch) | |
tree | 96d19162abf0b95159bbd4381a40897bb96efe47 /apps/user_ldap | |
parent | f7632f2fc4660ebc74240a9dd738b6e03a711eaa (diff) | |
parent | 967955358c2693aafb1e43795b09cf24e460929b (diff) | |
download | nextcloud-server-c995428431c5b1a6b593cd960d63a25d027b9039.tar.gz nextcloud-server-c995428431c5b1a6b593cd960d63a25d027b9039.zip |
Merge pull request #37903 from nextcloud/fix/user_ldap-fix-multiple-ldap-support
Fix multiple LDAP configuration support by fixing AccessFactory
Diffstat (limited to 'apps/user_ldap')
-rw-r--r-- | apps/user_ldap/lib/AccessFactory.php | 7 | ||||
-rw-r--r-- | apps/user_ldap/lib/Jobs/Sync.php | 19 | ||||
-rw-r--r-- | apps/user_ldap/tests/Jobs/SyncTest.php | 3 |
3 files changed, 6 insertions, 23 deletions
diff --git a/apps/user_ldap/lib/AccessFactory.php b/apps/user_ldap/lib/AccessFactory.php index f0820f1444f..693f7e8ba12 100644 --- a/apps/user_ldap/lib/AccessFactory.php +++ b/apps/user_ldap/lib/AccessFactory.php @@ -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, diff --git a/apps/user_ldap/lib/Jobs/Sync.php b/apps/user_ldap/lib/Jobs/Sync.php index 1ba24af5399..f8a9b14d02f 100644 --- a/apps/user_ldap/lib/Jobs/Sync.php +++ b/apps/user_ldap/lib/Jobs/Sync.php @@ -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); } } } diff --git a/apps/user_ldap/tests/Jobs/SyncTest.php b/apps/user_ldap/tests/Jobs/SyncTest.php index 8d23efb4da8..3d9fc54e631 100644 --- a/apps/user_ldap/tests/Jobs/SyncTest.php +++ b/apps/user_ldap/tests/Jobs/SyncTest.php @@ -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() { |