fix: changing private key manually won't trigger a notification
This commit is contained in:
@@ -31,16 +31,16 @@ class ShowPrivateKey extends Component
|
|||||||
$originalPrivateKeyId = $this->server->getOriginal('private_key_id');
|
$originalPrivateKeyId = $this->server->getOriginal('private_key_id');
|
||||||
try {
|
try {
|
||||||
$this->server->update(['private_key_id' => $privateKeyId]);
|
$this->server->update(['private_key_id' => $privateKeyId]);
|
||||||
['uptime' => $uptime, 'error' => $error] = $this->server->validateConnection();
|
['uptime' => $uptime, 'error' => $error] = $this->server->validateConnection(justCheckingNewKey: true);
|
||||||
if ($uptime) {
|
if ($uptime) {
|
||||||
$this->dispatch('success', 'Private key updated successfully.');
|
$this->dispatch('success', 'Private key updated successfully.');
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception('Server is not reachable.<br><br>Check this <a target="_blank" class="underline" href="https://coolify.io/docs/knowledge-base/server/openssh">documentation</a> for further help.<br><br>Error: '.$error);
|
throw new \Exception($error);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->server->update(['private_key_id' => $originalPrivateKeyId]);
|
$this->server->update(['private_key_id' => $originalPrivateKeyId]);
|
||||||
$this->server->validateConnection();
|
$this->server->validateConnection();
|
||||||
$this->dispatch('error', 'Failed to update private key: '.$e->getMessage());
|
$this->dispatch('error', $e->getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
$this->dispatch('refreshServerShow');
|
$this->dispatch('refreshServerShow');
|
||||||
$this->server->refresh();
|
$this->server->refresh();
|
||||||
|
|||||||
@@ -1057,7 +1057,7 @@ $schema://$host {
|
|||||||
$this->team->notify(new Unreachable($this));
|
$this->team->notify(new Unreachable($this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateConnection($isManualCheck = true)
|
public function validateConnection(bool $isManualCheck = true, bool $justCheckingNewKey = false)
|
||||||
{
|
{
|
||||||
config()->set('constants.ssh.mux_enabled', ! $isManualCheck);
|
config()->set('constants.ssh.mux_enabled', ! $isManualCheck);
|
||||||
|
|
||||||
@@ -1077,6 +1077,9 @@ $schema://$host {
|
|||||||
|
|
||||||
return ['uptime' => true, 'error' => null];
|
return ['uptime' => true, 'error' => null];
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
if ($justCheckingNewKey) {
|
||||||
|
return ['uptime' => false, 'error' => 'This key is not valid for this server.'];
|
||||||
|
}
|
||||||
if ($this->settings->is_reachable === true) {
|
if ($this->settings->is_reachable === true) {
|
||||||
$this->settings->is_reachable = false;
|
$this->settings->is_reachable = false;
|
||||||
$this->settings->save();
|
$this->settings->save();
|
||||||
|
|||||||
Reference in New Issue
Block a user