refactor: Remove unnecessary code in PrivateKey model
This commit is contained in:
parent
5b00b66f24
commit
c0898f0568
1 changed files with 1 additions and 5 deletions
|
|
@ -52,7 +52,6 @@ protected static function booted()
|
|||
}
|
||||
|
||||
$key->fingerprint = self::generateFingerprint($key->private_key);
|
||||
|
||||
if (self::fingerprintExists($key->fingerprint, $key->id)) {
|
||||
throw ValidationException::withMessages([
|
||||
'private_key' => ['This private key already exists.'],
|
||||
|
|
@ -142,10 +141,7 @@ public static function validateAndExtractPublicKey($privateKey)
|
|||
public function storeInFileSystem()
|
||||
{
|
||||
$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);
|
||||
$file = Storage::disk('ssh-keys')->get($filename);
|
||||
echo 'File: '.$file."\n";
|
||||
|
||||
return "/var/www/html/storage/app/ssh/keys/{$filename}";
|
||||
}
|
||||
|
|
@ -224,7 +220,7 @@ private static function fingerprintExists($fingerprint, $excludeId = null)
|
|||
{
|
||||
$query = self::where('fingerprint', $fingerprint);
|
||||
|
||||
if ($excludeId) {
|
||||
if (! is_null($excludeId)) {
|
||||
$query->where('id', '!=', $excludeId);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue