LDAP clear cache on config modification also when done via API or CLI

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2018-12-17 00:31:27 +01:00
parent 9322f5064a
commit feb5366a42
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
3 changed files with 19 additions and 1 deletions

View 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();
});
}
}

View 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();
}
}

View 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) {