Fix: Make sure in use private keys are not deleted

This commit is contained in:
peaklabs-dev
2024-09-17 14:32:44 +02:00
parent 2ec66fd146
commit 6a6b947fba

View File

@@ -144,6 +144,10 @@ class PrivateKey extends BaseModel
public static function deleteFromStorage(self $privateKey) 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}"; $filename = "ssh@{$privateKey->uuid}";
Storage::disk('ssh-keys')->delete($filename); Storage::disk('ssh-keys')->delete($filename);
} }