refactor: Remove unnecessary code in PrivateKey model
This commit is contained in:
@@ -52,7 +52,6 @@ class PrivateKey extends BaseModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
$key->fingerprint = self::generateFingerprint($key->private_key);
|
$key->fingerprint = self::generateFingerprint($key->private_key);
|
||||||
|
|
||||||
if (self::fingerprintExists($key->fingerprint, $key->id)) {
|
if (self::fingerprintExists($key->fingerprint, $key->id)) {
|
||||||
throw ValidationException::withMessages([
|
throw ValidationException::withMessages([
|
||||||
'private_key' => ['This private key already exists.'],
|
'private_key' => ['This private key already exists.'],
|
||||||
@@ -142,10 +141,7 @@ class PrivateKey extends BaseModel
|
|||||||
public function storeInFileSystem()
|
public function storeInFileSystem()
|
||||||
{
|
{
|
||||||
$filename = "ssh_key@{$this->uuid}";
|
$filename = "ssh_key@{$this->uuid}";
|
||||||
echo 'Storing key: '.$filename."\n".'Private key: '.$this->private_key."\n";
|
|
||||||
Storage::disk('ssh-keys')->put($filename, $this->private_key);
|
Storage::disk('ssh-keys')->put($filename, $this->private_key);
|
||||||
$file = Storage::disk('ssh-keys')->get($filename);
|
|
||||||
echo 'File: '.$file."\n";
|
|
||||||
|
|
||||||
return "/var/www/html/storage/app/ssh/keys/{$filename}";
|
return "/var/www/html/storage/app/ssh/keys/{$filename}";
|
||||||
}
|
}
|
||||||
@@ -224,7 +220,7 @@ class PrivateKey extends BaseModel
|
|||||||
{
|
{
|
||||||
$query = self::where('fingerprint', $fingerprint);
|
$query = self::where('fingerprint', $fingerprint);
|
||||||
|
|
||||||
if ($excludeId) {
|
if (! is_null($excludeId)) {
|
||||||
$query->where('id', '!=', $excludeId);
|
$query->where('id', '!=', $excludeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user