mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 22:16:15 +00:00
#591 - fix server-ssh-keys
This commit is contained in:
@ -10,6 +10,7 @@
|
||||
use App\Models\SshKey;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
use Spatie\RouteAttributes\Attributes\Delete;
|
||||
@ -40,8 +41,14 @@ public function store(Request $request, Server $server): RedirectResponse
|
||||
{
|
||||
$this->authorize('createServer', [SshKey::class, $server]);
|
||||
|
||||
/** @var SshKey $sshKey */
|
||||
$sshKey = user()->sshKeys()->findOrFail($request->input('key'));
|
||||
/** @var ?SshKey $sshKey */
|
||||
$sshKey = user()->sshKeys()->find($request->input('key'));
|
||||
|
||||
if (! $sshKey) {
|
||||
throw ValidationException::withMessages([
|
||||
'key' => ['The selected SSH key does not exist.'],
|
||||
]);
|
||||
}
|
||||
|
||||
app(DeployKeyToServer::class)->deploy($server, $sshKey);
|
||||
|
||||
|
Reference in New Issue
Block a user