diff --git a/app/Livewire/Server/Advanced.php b/app/Livewire/Server/Advanced.php index 760c4df0d..bbc3bd96a 100644 --- a/app/Livewire/Server/Advanced.php +++ b/app/Livewire/Server/Advanced.php @@ -27,9 +27,6 @@ class Advanced extends Component #[Validate(['integer', 'min:1'])] public int $dynamicTimeout = 1; - #[Validate(['boolean'])] - public bool $isTerminalEnabled = false; - public function mount(string $server_uuid) { try { @@ -42,36 +39,7 @@ public function mount(string $server_uuid) } } - public function toggleTerminal($password) - { - try { - // Check if user is admin or owner - if (! auth()->user()->isAdmin()) { - throw new \Exception('Only team administrators and owners can modify terminal access.'); - } - // Verify password unless two-step confirmation is disabled - if (! data_get(InstanceSettings::get(), 'disable_two_step_confirmation')) { - if (! Hash::check($password, Auth::user()->password)) { - $this->addError('password', 'The provided password is incorrect.'); - - return; - } - } - - // Toggle the terminal setting - $this->server->settings->is_terminal_enabled = ! $this->server->settings->is_terminal_enabled; - $this->server->settings->save(); - - // Update the local property - $this->isTerminalEnabled = $this->server->settings->is_terminal_enabled; - - $status = $this->isTerminalEnabled ? 'enabled' : 'disabled'; - $this->dispatch('success', "Terminal access has been {$status}."); - } catch (\Throwable $e) { - return handleError($e, $this); - } - } public function syncData(bool $toModel = false) { @@ -88,7 +56,6 @@ public function syncData(bool $toModel = false) $this->dynamicTimeout = $this->server->settings->dynamic_timeout; $this->serverDiskUsageNotificationThreshold = $this->server->settings->server_disk_usage_notification_threshold; $this->serverDiskUsageCheckFrequency = $this->server->settings->server_disk_usage_check_frequency; - $this->isTerminalEnabled = $this->server->settings->is_terminal_enabled; } } diff --git a/app/Livewire/Server/Security/TerminalAccess.php b/app/Livewire/Server/Security/TerminalAccess.php new file mode 100644 index 000000000..c5898314b --- /dev/null +++ b/app/Livewire/Server/Security/TerminalAccess.php @@ -0,0 +1,79 @@ +server = Server::ownedByCurrentTeam()->whereUuid($server_uuid)->firstOrFail(); + $this->parameters = get_route_parameters(); + $this->syncData(); + + } catch (\Throwable) { + return redirect()->route('server.index'); + } + } + + public function toggleTerminal($password) + { + try { + // Check if user is admin or owner + if (! auth()->user()->isAdmin()) { + throw new \Exception('Only team administrators and owners can modify terminal access.'); + } + + // Verify password unless two-step confirmation is disabled + if (! data_get(InstanceSettings::get(), 'disable_two_step_confirmation')) { + if (! Hash::check($password, Auth::user()->password)) { + $this->addError('password', 'The provided password is incorrect.'); + + return; + } + } + + // Toggle the terminal setting + $this->server->settings->is_terminal_enabled = ! $this->server->settings->is_terminal_enabled; + $this->server->settings->save(); + + // Update the local property + $this->isTerminalEnabled = $this->server->settings->is_terminal_enabled; + + $status = $this->isTerminalEnabled ? 'enabled' : 'disabled'; + $this->dispatch('success', "Terminal access has been {$status}."); + } catch (\Throwable $e) { + return handleError($e, $this); + } + } + + public function syncData(bool $toModel = false) + { + if ($toModel) { + $this->authorize('update', $this->server); + $this->validate(); + // No other fields to sync for terminal access + } else { + $this->isTerminalEnabled = $this->server->settings->is_terminal_enabled; + } + } + + public function render() + { + return view('livewire.server.security.terminal-access'); + } +} \ No newline at end of file diff --git a/resources/views/components/server/sidebar-security.blade.php b/resources/views/components/server/sidebar-security.blade.php index 6f6d9d8a0..141d32f3b 100644 --- a/resources/views/components/server/sidebar-security.blade.php +++ b/resources/views/components/server/sidebar-security.blade.php @@ -3,4 +3,8 @@ href="{{ route('server.security.patches', $parameters) }}"> Server Patching + + Terminal Access + diff --git a/resources/views/livewire/server/advanced.blade.php b/resources/views/livewire/server/advanced.blade.php index 308a9eed2..6622961c5 100644 --- a/resources/views/livewire/server/advanced.blade.php +++ b/resources/views/livewire/server/advanced.blade.php @@ -14,47 +14,6 @@