An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix: generate new key
Andras Bacsai1cf036bbc609
diff --git a/app/Http/Livewire/PrivateKey/Create.php b/app/Http/Livewire/PrivateKey/Create.phpindex cf8414b3e1..4dcaedbe2b 100644--- a/app/Http/Livewire/PrivateKey/Create.php+++ b/app/Http/Livewire/PrivateKey/Create.php@@ -3,16 +3,20 @@namespace App\Http\Livewire\PrivateKey;use App\Models\PrivateKey;+use DanHarrin\LivewireRateLimiting\WithRateLimiting;use Livewire\Component;use phpseclib3\Crypt\PublicKeyLoader;class Create extends Component{- public ?string $from = null;+ use WithRateLimiting;public string $name;- public ?string $description = null;public string $value;++ public ?string $from = null;+ public ?string $description = null;public ?string $publicKey = null;+protected $rules = ['name' => 'required|string','value' => 'required|string',@@ -24,9 +28,14 @@ class Create extends Componentpublic function generateNewKey(){- $this->name = generate_random_name();- $this->description = 'Created by Coolify';- ['private' => $this->value, 'public' => $this->publicKey] = generateSSHKey();+ try {+ $this->rateLimit(10);+ $this->name = generate_random_name();+ $this->description = 'Created by Coolify';+ ['private' => $this->value, 'public' => $this->publicKey] = generateSSHKey();+ } catch(\Throwable $e) {+ return handleError($e, $this);+ }}public function updated($updateProperty){@@ -34,7 +43,11 @@ class Create extends Componenttry {$this->publicKey = PublicKeyLoader::load($this->$updateProperty)->getPublicKey()->toString('OpenSSH',['comment' => '']);} catch (\Throwable $e) {- $this->publicKey = "Invalid private key";+ if ($this->$updateProperty === "") {+ $this->publicKey = "";+ } else {+ $this->publicKey = "Invalid private key";+ }}}$this->validateOnly($updateProperty);diff --git a/resources/views/components/forms/textarea.blade.php b/resources/views/components/forms/textarea.blade.phpindex be45629ab7..bf09486050 100644--- a/resources/views/components/forms/textarea.blade.php+++ b/resources/views/components/forms/textarea.blade.php@@ -30,7 +30,7 @@</label>@endif<textarea placeholder="{{ $placeholder }}" {{ $attributes->merge(['class' => $defaultClass]) }}- @if ($realtimeValidation) wire:model.debounce.500ms="{{ $id }}"+ @if ($realtimeValidation) wire:model.debounce.200ms="{{ $id }}"@elsewire:model.defer={{ $value ?? $id }}wire:dirty.class="input-warning"@endifdiff --git a/resources/views/livewire/private-key/create.blade.php b/resources/views/livewire/private-key/create.blade.phpindex 3d9ade364e..b269e5ce46 100644--- a/resources/views/livewire/private-key/create.blade.php+++ b/resources/views/livewire/private-key/create.blade.php@@ -1,4 +1,5 @@<div>+ <x-forms.button class="mb-4" wire:click="generateNewKey">Generate new SSH key for me</x-forms.button><form class="flex flex-col gap-2" wire:submit.prevent='createPrivateKey'><div class="flex gap-2"><x-forms.input id="name" label="Name" required />@@ -6,11 +7,10 @@</div><x-forms.textarea realtimeValidation id="value" rows="10"placeholder="-----BEGIN OPENSSH PRIVATE KEY-----" label="Private Key" required />- <x-forms.button wire:click="generateNewKey">Generate new SSH key for me</x-forms.button>- <x-forms.textarea id="publicKey" rows="6" readonly label="Public Key" />- <span class="font-bold text-warning">ACTION REQUIRED: Copy the 'Public Key' to your server's+ <x-forms.input id="publicKey" readonly label="Public Key" />+ <span class="pt-2 pb-4 font-bold text-warning">ACTION REQUIRED: Copy the 'Public Key' to your server's~/.ssh/authorized_keys- file.</span>+ file</span><x-forms.button type="submit">Save Private Key</x-forms.button>