Skip to content

Commit 39cbee6

Browse files
committed
fixed checkDaemonConnection
Signed-off-by: Oleksander Piskun <[email protected]>
1 parent 0725b6a commit 39cbee6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/Controller/DaemonConfigController.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,24 @@ public function checkDaemonConnection(array $daemonParams): Response {
134134
$haproxyPassword = $daemonParams['deploy_config']['haproxy_password'] ?? null;
135135

136136
if ($haproxyPassword === 'dummySecret123') {
137-
// If the secret is "dummySecret123" we check if such record is present in DB
137+
// For cases when the password itself is 'dummySecret123'
138+
$daemonParams['deploy_config']['haproxy_password'] = $this->crypto->encrypt($haproxyPassword);
139+
140+
// Check if such record is present in the DB
138141
$daemonConfig = $this->daemonConfigService->getDaemonConfigByName($daemonParams['name']);
139142
if ($daemonConfig !== null) {
143+
// such Daemon config already present in the DB
140144
$haproxyPasswordDB = $daemonConfig->getDeployConfig()['haproxy_password'] ?? "";
141145
if ($haproxyPasswordDB) {
142-
// if there is a record in the DB and there is a password,
143-
// then we request it from the DB instead of the “masked” one
146+
// get password from the DB instead of the “masked” one
144147
$daemonParams['deploy_config']['haproxy_password'] = $haproxyPasswordDB;
145148
}
146149
}
147150
}
151+
elseif (!empty($haproxyPassword)) {
152+
// New password provided, encrypt it, as "initGuzzleClient" expects to receive encrypted password
153+
$daemonParams['deploy_config']['haproxy_password'] = $this->crypto->encrypt($haproxyPassword);
154+
}
148155

149156
$daemonConfig = new DaemonConfig([
150157
'name' => $daemonParams['name'],

0 commit comments

Comments
 (0)