Adapt GetAndGenerateSecret() to get() and set()

Signed-off-by: Pablo Zmdl <pablo@nextcloud.com>
This commit is contained in:
Pablo Zmdl 2026-01-20 18:22:40 +01:00
parent e2ca4af0b9
commit e95c13b86d

View file

@ -71,17 +71,17 @@ class ConfigurationManager
return ''; return '';
} }
$config = $this->GetConfig(); $secrets = $this->get('secrets', []);
if(!isset($config['secrets'][$secretId])) { if (!isset($secrets[$secretId])) {
$config['secrets'][$secretId] = bin2hex(random_bytes(24)); $secrets[$secretId] = bin2hex(random_bytes(24));
$this->WriteConfig($config); $this->set('secrets', $secrets);
} }
if ($secretId === 'BORGBACKUP_PASSWORD' && !file_exists(DataConst::GetBackupSecretFile())) { if ($secretId === 'BORGBACKUP_PASSWORD' && !file_exists(DataConst::GetBackupSecretFile())) {
$this->DoubleSafeBackupSecret($config['secrets'][$secretId]); $this->DoubleSafeBackupSecret($secrets[$secretId]);
} }
return $config['secrets'][$secretId]; return $secrets[$secretId];
} }
public function GetRegisteredSecret(string $secretId) : string { public function GetRegisteredSecret(string $secretId) : string {