From 6a6b947fbaeaeec6fa37b621110b344a2e3b5b1d Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:32:44 +0200 Subject: [PATCH] Fix: Make sure in use private keys are not deleted --- app/Models/PrivateKey.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Models/PrivateKey.php b/app/Models/PrivateKey.php index f2fa9c9cf..fef464823 100644 --- a/app/Models/PrivateKey.php +++ b/app/Models/PrivateKey.php @@ -144,6 +144,10 @@ class PrivateKey extends BaseModel public static function deleteFromStorage(self $privateKey) { + if ($privateKey->isInUse()) { + throw new \Exception('Cannot delete a private key that is in use.'); + } + $filename = "ssh@{$privateKey->uuid}"; Storage::disk('ssh-keys')->delete($filename); }