diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2017-11-09 09:26:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-09 09:26:51 +0100 |
commit | 2bfa1ce5c3a23468ef2830680062869c65094b74 (patch) | |
tree | e94383026953d8307d2f3266caf17801fcd8665c /apps/user_ldap/lib | |
parent | aa525d89e889216d17185a6934699a8f8ba7aa91 (diff) | |
parent | 7b0868ddac20c020b31310471c06b9a3a78ed5bd (diff) | |
download | nextcloud-server-2bfa1ce5c3a23468ef2830680062869c65094b74.tar.gz nextcloud-server-2bfa1ce5c3a23468ef2830680062869c65094b74.zip |
Merge pull request #5568 from nextcloud/ldap-agent-credentials-safe
Ldap agent credentials save
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r-- | apps/user_ldap/lib/Configuration.php | 14 | ||||
-rw-r--r-- | apps/user_ldap/lib/Connection.php | 2 |
2 files changed, 12 insertions, 4 deletions
diff --git a/apps/user_ldap/lib/Configuration.php b/apps/user_ldap/lib/Configuration.php index bf8a9095a68..d971f2ffefd 100644 --- a/apps/user_ldap/lib/Configuration.php +++ b/apps/user_ldap/lib/Configuration.php @@ -37,9 +37,13 @@ namespace OCA\User_LDAP; * @property int ldapPagingSize holds an integer */ class Configuration { - protected $configPrefix = null; protected $configRead = false; + /** + * @var string[] pre-filled with one reference key so that at least one entry is written on save request and + * the config ID is registered + */ + protected $unsavedChanges = ['ldapConfigurationActive' => 'ldapConfigurationActive']; //settings protected $config = array( @@ -187,7 +191,9 @@ class Configuration { $this->$setMethod($key, $val); if(is_array($applied)) { $applied[] = $inputKey; + // storing key as index avoids duplication, and as value for simplicity } + $this->unsavedChanges[$key] = $key; } return null; } @@ -240,11 +246,12 @@ class Configuration { } /** - * saves the current Configuration in the database + * saves the current config changes in the database */ public function saveConfiguration() { $cta = array_flip($this->getConfigTranslationArray()); - foreach($this->config as $key => $value) { + foreach($this->unsavedChanges as $key) { + $value = $this->config[$key]; switch ($key) { case 'ldapAgentPassword': $value = base64_encode($value); @@ -275,6 +282,7 @@ class Configuration { } $this->saveValue($cta[$key], $value); } + $this->unsavedChanges = []; } /** diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php index 0f10874bc2f..79d66189c27 100644 --- a/apps/user_ldap/lib/Connection.php +++ b/apps/user_ldap/lib/Connection.php @@ -150,7 +150,7 @@ class Connection extends LDAPUtility { $this->configuration->$name = $value; $after = $this->configuration->$name; if($before !== $after) { - if ($this->configID !== '') { + if ($this->configID !== '' && $this->configID !== null) { $this->configuration->saveConfiguration(); } $this->validateConfiguration(); |