serverId = $serverId; $this->serverName = Server::find($serverId)?->name ?? ''; } public static function modalMaxWidth(): string { return 'lg'; } public function run(SshKeyProvisioner $provisioner): void { if ($this->done) { return; } $server = Server::find($this->serverId); if (! $server) { $this->error = __('common.server_not_found'); return; } $result = $provisioner->enableKeyOnlyAccess($server); $this->done = true; $this->ok = $result['ok']; $this->privateKey = $result['privateKey'] ?? null; $this->publicKey = $result['publicKey'] ?? null; $this->error = $result['ok'] ? null : ($result['error'] ?? __('modals.ssh_key_provision.error_unknown')); // A credential switch and/or a hardening change happened whenever a key was generated or // password auth was turned off — refresh the page state either way. $this->dispatch('hardeningApplied'); $this->dispatch('credentialChanged'); $this->dispatch('notify', message: $this->ok ? __('modals.ssh_key_provision.notify_ok', ['server' => $this->serverName]) : __('modals.ssh_key_provision.notify_failed')); } public function render() { return view('livewire.modals.ssh-key-provision'); } }