Skip to content

Commit 210ccc8

Browse files
committed
fix: encryption ky generation pb
1 parent a15e2f3 commit 210ccc8

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/Ubiquity/security/data/EncryptionManager.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
<?php
22
namespace Ubiquity\security\data;
33

4+
use Ubiquity\config\Configuration;
5+
use Ubiquity\config\EnvFile;
46
use Ubiquity\controllers\Startup;
57

68
/**
79
* Ubiquity\security\data$EncryptionManager
810
* This class is part of Ubiquity
911
*
1012
* @author jc
11-
* @version 1.0.1
13+
* @version 1.0.2
1214
*
1315
*/
1416
class EncryptionManager {
1517

16-
const ENCRYPTION_KEY_NAME = 'encryption-key';
18+
const ENCRYPTION_KEY_NAME = 'encryption_key';
1719

1820
/**
1921
*
@@ -39,9 +41,11 @@ public static function start(array &$config, ?string $cipher = Encryption::AES12
3941
$key = self::$encryptionInstance->getKey();
4042

4143
if ($oldKey !== $key) {
42-
$filename = \ROOT . 'config/config.php';
43-
$oConfig = include($filename);
44-
$oConfig[self::ENCRYPTION_KEY_NAME] = $key;
44+
$oConfig = Configuration::loadConfigWithoutEval('config');
45+
$oConfig[self::ENCRYPTION_KEY_NAME] = "getenv('".self::ENCRYPTION_KEY_NAME."')";
46+
$envArray=EnvFile::load();
47+
$envArray[self::ENCRYPTION_KEY_NAME]=$key;
48+
EnvFile::save($envArray);
4549
Startup::saveConfig($oConfig);
4650
}
4751
}

0 commit comments

Comments
 (0)