From 2932d9a6e0ed99886c5da2a896338452a8ac5512 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Fri, 15 Nov 2024 12:10:39 +0100 Subject: [PATCH] fix ssh key migration broken with the new team check --- app/Models/PrivateKey.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Models/PrivateKey.php b/app/Models/PrivateKey.php index fe8a594db..fab1f1de7 100644 --- a/app/Models/PrivateKey.php +++ b/app/Models/PrivateKey.php @@ -218,9 +218,14 @@ class PrivateKey extends BaseModel private static function fingerprintExists($fingerprint, $excludeId = null) { - return self::query() - ->where('fingerprint', $fingerprint) - ->where('team_id', currentTeam()->id) + $query = self::query() + ->where('fingerprint', $fingerprint); + + if (currentTeam()) { + $query->where('team_id', currentTeam()->id); + } + + return $query ->when($excludeId, fn ($query) => $query->where('id', '!=', $excludeId)) ->exists(); }