]> source.dussan.org Git - nextcloud-server.git/commitdiff
LDAP clear cache on config modification also when done via API or CLI 13120/head
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Sun, 16 Dec 2018 23:31:27 +0000 (00:31 +0100)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Mon, 17 Dec 2018 12:19:28 +0000 (13:19 +0100)
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
apps/user_ldap/lib/AppInfo/Application.php
apps/user_ldap/lib/Command/SetConfig.php
apps/user_ldap/lib/Controller/ConfigAPIController.php

index 6d5c416f04f36b55c7bb16f532c2a7dc70360d07..59d7cdb49245e45934fea9461778071375f7b94c 100644 (file)
@@ -24,6 +24,8 @@
 namespace OCA\User_LDAP\AppInfo;
 
 use OCA\User_LDAP\Controller\RenewPasswordController;
+use OCA\User_LDAP\ILDAPWrapper;
+use OCA\User_LDAP\LDAP;
 use OCP\AppFramework\App;
 use OCP\AppFramework\IAppContainer;
 use OCP\IL10N;
@@ -50,5 +52,9 @@ class Application extends App {
                                $server->getURLGenerator()
                        );
                });
+
+               $container->registerService(ILDAPWrapper::class, function () {
+                       return new LDAP();
+               });
        }
 }
index db656558efc77cfdb5dd3ab4cce291ad2c62bb3d..cf73874ade82d9d83d67865f9e002ceca340b9fe 100644 (file)
@@ -26,6 +26,8 @@
 
 namespace OCA\User_LDAP\Command;
 
+use OCA\User_LDAP\ConnectionFactory;
+use OCA\User_LDAP\LDAP;
 use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputInterface;
@@ -83,5 +85,8 @@ class SetConfig extends Command {
                $configHolder = new Configuration($configID);
                $configHolder->$key = $value;
                $configHolder->saveConfiguration();
+
+               $connectionFactory = new ConnectionFactory(new LDAP());
+               $connectionFactory->get($configID)->clearCache();
        }
 }
index e000bd4e709ae654c330205634a8ef2034e123ab..d5b33e41044ce3ce12316f8ce13b3936477cc9b2 100644 (file)
@@ -27,6 +27,7 @@ use OC\CapabilitiesManager;
 use OC\Core\Controller\OCSController;
 use OC\Security\IdentityProof\Manager;
 use OCA\User_LDAP\Configuration;
+use OCA\User_LDAP\ConnectionFactory;
 use OCA\User_LDAP\Helper;
 use OCP\AppFramework\Http\DataResponse;
 use OCP\AppFramework\OCS\OCSBadRequestException;
@@ -45,6 +46,9 @@ class ConfigAPIController extends OCSController {
        /** @var ILogger */
        private $logger;
 
+       /** @var ConnectionFactory */
+       private $connectionFactory;
+
        public function __construct(
                $appName,
                IRequest $request,
@@ -53,7 +57,8 @@ class ConfigAPIController extends OCSController {
                IUserManager $userManager,
                Manager $keyManager,
                Helper $ldapHelper,
-               ILogger $logger
+               ILogger $logger,
+               ConnectionFactory $connectionFactory
        ) {
                parent::__construct(
                        $appName,
@@ -67,6 +72,7 @@ class ConfigAPIController extends OCSController {
 
                $this->ldapHelper = $ldapHelper;
                $this->logger = $logger;
+               $this->connectionFactory = $connectionFactory;
        }
 
        /**
@@ -198,6 +204,7 @@ class ConfigAPIController extends OCSController {
                        }
 
                        $configuration->saveConfiguration();
+                       $this->connectionFactory->get($configID)->clearCache();
                } catch(OCSException $e) {
                        throw $e;
                } catch (\Exception $e) {