fix: timezone settings validation
This commit is contained in:
@@ -127,7 +127,14 @@ class Show extends Component
|
|||||||
$this->server->settings->sentinel_custom_url = $this->sentinelCustomUrl;
|
$this->server->settings->sentinel_custom_url = $this->sentinelCustomUrl;
|
||||||
$this->server->settings->is_sentinel_enabled = $this->isSentinelEnabled;
|
$this->server->settings->is_sentinel_enabled = $this->isSentinelEnabled;
|
||||||
$this->server->settings->is_sentinel_debug_enabled = $this->isSentinelDebugEnabled;
|
$this->server->settings->is_sentinel_debug_enabled = $this->isSentinelDebugEnabled;
|
||||||
|
|
||||||
|
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->server_timezone = $this->serverTimezone;
|
||||||
|
}
|
||||||
|
|
||||||
$this->server->settings->save();
|
$this->server->settings->save();
|
||||||
} else {
|
} else {
|
||||||
$this->name = $this->server->name;
|
$this->name = $this->server->name;
|
||||||
|
@@ -139,6 +139,14 @@ class Index extends Component
|
|||||||
$error_show = false;
|
$error_show = false;
|
||||||
$this->server = Server::findOrFail(0);
|
$this->server = Server::findOrFail(0);
|
||||||
$this->resetErrorBag();
|
$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) {
|
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.');
|
$this->addError('settings.public_port_min', 'The minimum port must be lower than the maximum port.');
|
||||||
|
|
||||||
|
@@ -385,6 +385,11 @@ function validate_cron_expression($expression_to_validate): bool
|
|||||||
|
|
||||||
return $isValid;
|
return $isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function validate_timezone(string $timezone): bool
|
||||||
|
{
|
||||||
|
return in_array($timezone, timezone_identifiers_list());
|
||||||
|
}
|
||||||
function send_internal_notification(string $message): void
|
function send_internal_notification(string $message): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
@@ -110,8 +110,7 @@
|
|||||||
wire:dirty.class.remove='dark:focus:ring-coolgray-300 dark:ring-coolgray-300'
|
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"
|
wire:dirty.class="dark:focus:ring-warning dark:ring-warning" x-model="search"
|
||||||
@focus="open = true" @click.away="open = false" @input="open = true"
|
@focus="open = true" @click.away="open = false" @input="open = true"
|
||||||
class="w-full input" :placeholder="placeholder"
|
class="w-full input" :placeholder="placeholder" wire:model="serverTimezone">
|
||||||
wire:model.debounce.300ms="serverTimezone">
|
|
||||||
<svg class="absolute right-0 mr-2 w-4 h-4" xmlns="http://www.w3.org/2000/svg"
|
<svg class="absolute right-0 mr-2 w-4 h-4" xmlns="http://www.w3.org/2000/svg"
|
||||||
fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
|
fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
|
||||||
@click="open = true">
|
@click="open = true">
|
||||||
@@ -124,7 +123,7 @@
|
|||||||
<template
|
<template
|
||||||
x-for="timezone in timezones.filter(tz => tz.toLowerCase().includes(search.toLowerCase()))"
|
x-for="timezone in timezones.filter(tz => tz.toLowerCase().includes(search.toLowerCase()))"
|
||||||
:key="timezone">
|
:key="timezone">
|
||||||
<div @click="search = timezone; open = false; $wire.set('serverTimezone', timezone)"
|
<div @click="search = timezone; open = false; $wire.set('serverTimezone', timezone); $wire.submit()"
|
||||||
class="px-4 py-2 text-gray-800 cursor-pointer hover:bg-gray-100 dark:hover:bg-coolgray-300 dark:text-gray-200"
|
class="px-4 py-2 text-gray-800 cursor-pointer hover:bg-gray-100 dark:hover:bg-coolgray-300 dark:text-gray-200"
|
||||||
x-text="timezone"></div>
|
x-text="timezone"></div>
|
||||||
</template>
|
</template>
|
||||||
|
@@ -40,14 +40,13 @@
|
|||||||
helper="Timezone for the Coolify instance. This is used for the update check and automatic update frequency." />
|
helper="Timezone for the Coolify instance. This is used for the update check and automatic update frequency." />
|
||||||
</div>
|
</div>
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<div class="inline-flex items-center relative w-full">
|
<div class="inline-flex relative items-center w-full">
|
||||||
<input autocomplete="off"
|
<input autocomplete="off"
|
||||||
wire:dirty.class.remove='dark:focus:ring-coolgray-300 dark:ring-coolgray-300'
|
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"
|
wire:dirty.class="dark:focus:ring-warning dark:ring-warning" x-model="search"
|
||||||
@focus="open = true" @click.away="open = false" @input="open = true"
|
@focus="open = true" @click.away="open = false" @input="open = true"
|
||||||
class="w-full input " :placeholder="placeholder"
|
class="w-full input" :placeholder="placeholder" wire:model="instance_timezone">
|
||||||
wire:model.debounce.300ms="instance_timezone">
|
<svg class="absolute right-0 mr-2 w-4 h-4" xmlns="http://www.w3.org/2000/svg"
|
||||||
<svg class="absolute right-0 w-4 h-4 mr-2" xmlns="http://www.w3.org/2000/svg"
|
|
||||||
fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
|
fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
|
||||||
@click="open = true">
|
@click="open = true">
|
||||||
<path stroke-linecap="round" stroke-linejoin="round"
|
<path stroke-linecap="round" stroke-linejoin="round"
|
||||||
@@ -55,18 +54,17 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<div x-show="open"
|
<div x-show="open"
|
||||||
class="absolute z-50 w-full mt-1 bg-white dark:bg-coolgray-100 border dark:border-coolgray-200 rounded-md shadow-lg max-h-60 overflow-auto scrollbar overflow-x-hidden">
|
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">
|
||||||
<template
|
<template
|
||||||
x-for="timezone in timezones.filter(tz => tz.toLowerCase().includes(search.toLowerCase()))"
|
x-for="timezone in timezones.filter(tz => tz.toLowerCase().includes(search.toLowerCase()))"
|
||||||
:key="timezone">
|
:key="timezone">
|
||||||
<div @click="search = timezone; open = false; $wire.set('instance_timezone', timezone)"
|
<div @click="search = timezone; open = false; $wire.set('instance_timezone', timezone); $wire.submit()"
|
||||||
class="px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-coolgray-300 text-gray-800 dark:text-gray-200"
|
class="px-4 py-2 text-gray-800 cursor-pointer hover:bg-gray-100 dark:hover:bg-coolgray-300 dark:text-gray-200"
|
||||||
x-text="timezone"></div>
|
x-text="timezone"></div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="flex gap-2 md:flex-row flex-col w-full">
|
<div class="flex gap-2 md:flex-row flex-col w-full">
|
||||||
<x-forms.input id="public_ipv4" type="password" label="Instance's IPv4"
|
<x-forms.input id="public_ipv4" type="password" label="Instance's IPv4"
|
||||||
|
Reference in New Issue
Block a user