diff --git a/app/Livewire/Server/Show.php b/app/Livewire/Server/Show.php index bb9188f1c..5a1743f96 100644 --- a/app/Livewire/Server/Show.php +++ b/app/Livewire/Server/Show.php @@ -127,7 +127,14 @@ class Show extends Component $this->server->settings->sentinel_custom_url = $this->sentinelCustomUrl; $this->server->settings->is_sentinel_enabled = $this->isSentinelEnabled; $this->server->settings->is_sentinel_debug_enabled = $this->isSentinelDebugEnabled; - $this->server->settings->server_timezone = $this->serverTimezone; + + if (! validate_timezone($this->serverTimezone)) { + $this->serverTimezone = config('app.timezone'); + throw new \Exception('Invalid timezone.'); + } else { + $this->server->settings->server_timezone = $this->serverTimezone; + } + $this->server->settings->save(); } else { $this->name = $this->server->name; diff --git a/app/Livewire/Settings/Index.php b/app/Livewire/Settings/Index.php index 2991b8ae8..55ba49867 100644 --- a/app/Livewire/Settings/Index.php +++ b/app/Livewire/Settings/Index.php @@ -139,6 +139,14 @@ class Index extends Component $error_show = false; $this->server = Server::findOrFail(0); $this->resetErrorBag(); + + if (! validate_timezone($this->instance_timezone)) { + $this->instance_timezone = config('app.timezone'); + throw new \Exception('Invalid timezone.'); + } else { + $this->settings->instance_timezone = $this->instance_timezone; + } + if ($this->settings->public_port_min > $this->settings->public_port_max) { $this->addError('settings.public_port_min', 'The minimum port must be lower than the maximum port.'); diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 6e52dcde9..5e7295406 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -385,6 +385,11 @@ function validate_cron_expression($expression_to_validate): bool return $isValid; } + +function validate_timezone(string $timezone): bool +{ + return in_array($timezone, timezone_identifiers_list()); +} function send_internal_notification(string $message): void { try { diff --git a/resources/views/livewire/server/show.blade.php b/resources/views/livewire/server/show.blade.php index 818412f57..dcad8ac37 100644 --- a/resources/views/livewire/server/show.blade.php +++ b/resources/views/livewire/server/show.blade.php @@ -110,8 +110,7 @@ wire:dirty.class.remove='dark:focus:ring-coolgray-300 dark:ring-coolgray-300' wire:dirty.class="dark:focus:ring-warning dark:ring-warning" x-model="search" @focus="open = true" @click.away="open = false" @input="open = true" - class="w-full input" :placeholder="placeholder" - wire:model.debounce.300ms="serverTimezone"> + class="w-full input" :placeholder="placeholder" wire:model="serverTimezone"> @@ -124,7 +123,7 @@
diff --git a/resources/views/livewire/settings/index.blade.php b/resources/views/livewire/settings/index.blade.php index 447c4eca5..3262139d0 100644 --- a/resources/views/livewire/settings/index.blade.php +++ b/resources/views/livewire/settings/index.blade.php @@ -40,14 +40,13 @@ helper="Timezone for the Coolify instance. This is used for the update check and automatic update frequency." />
-
+
- +
+ class="overflow-auto overflow-x-hidden absolute z-50 mt-1 w-full max-h-60 bg-white rounded-md border shadow-lg dark:bg-coolgray-100 dark:border-coolgray-200 scrollbar">
-