fix: application domains should be http and https only
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Actions\Application\GenerateConfig;
|
|||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
use Spatie\Url\Url;
|
||||||
use Visus\Cuid2\Cuid2;
|
use Visus\Cuid2\Cuid2;
|
||||||
|
|
||||||
class General extends Component
|
class General extends Component
|
||||||
@@ -183,9 +184,7 @@ class General extends Component
|
|||||||
$storage->save();
|
$storage->save();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadComposeFile($isInit = false)
|
public function loadComposeFile($isInit = false)
|
||||||
@@ -242,23 +241,6 @@ class General extends Component
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updatedApplicationFqdn()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$this->application->fqdn = str($this->application->fqdn)->replaceEnd(',', '')->trim();
|
|
||||||
$this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim();
|
|
||||||
$this->application->fqdn = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) {
|
|
||||||
return str($domain)->trim()->lower();
|
|
||||||
});
|
|
||||||
$this->application->fqdn = $this->application->fqdn->unique()->implode(',');
|
|
||||||
$this->application->save();
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
$originalFqdn = $this->application->getOriginal('fqdn');
|
|
||||||
$this->application->fqdn = $originalFqdn;
|
|
||||||
return handleError($e, $this);
|
|
||||||
}
|
|
||||||
$this->resetDefaultLabels();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updatedApplicationBuildPack()
|
public function updatedApplicationBuildPack()
|
||||||
{
|
{
|
||||||
@@ -349,15 +331,18 @@ class General extends Component
|
|||||||
public function submit($showToaster = true)
|
public function submit($showToaster = true)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if ($this->application->isDirty('redirect')) {
|
Url::fromString($this->application->fqdn, ['http', 'https']);
|
||||||
$this->set_redirect();
|
|
||||||
}
|
|
||||||
$this->application->fqdn = str($this->application->fqdn)->replaceEnd(',', '')->trim();
|
$this->application->fqdn = str($this->application->fqdn)->replaceEnd(',', '')->trim();
|
||||||
$this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim();
|
$this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim();
|
||||||
$this->application->fqdn = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) {
|
$this->application->fqdn = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) {
|
||||||
return str($domain)->trim()->lower();
|
return str($domain)->trim()->lower();
|
||||||
});
|
});
|
||||||
$this->application->fqdn = $this->application->fqdn->unique()->implode(',');
|
$this->application->fqdn = $this->application->fqdn->unique()->implode(',');
|
||||||
|
$this->resetDefaultLabels();
|
||||||
|
|
||||||
|
if ($this->application->isDirty('redirect')) {
|
||||||
|
$this->set_redirect();
|
||||||
|
}
|
||||||
|
|
||||||
$this->checkFqdns();
|
$this->checkFqdns();
|
||||||
|
|
||||||
@@ -420,6 +405,10 @@ class General extends Component
|
|||||||
$this->application->save();
|
$this->application->save();
|
||||||
$showToaster && $this->dispatch('success', 'Application settings updated!');
|
$showToaster && $this->dispatch('success', 'Application settings updated!');
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
$originalFqdn = $this->application->getOriginal('fqdn');
|
||||||
|
if ($originalFqdn !== $this->application->fqdn) {
|
||||||
|
$this->application->fqdn = $originalFqdn;
|
||||||
|
}
|
||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
} finally {
|
} finally {
|
||||||
$this->dispatch('configurationChanged');
|
$this->dispatch('configurationChanged');
|
||||||
|
@@ -31,10 +31,14 @@ class Form extends Component
|
|||||||
public function generate_real_url()
|
public function generate_real_url()
|
||||||
{
|
{
|
||||||
if (data_get($this->application, 'fqdn')) {
|
if (data_get($this->application, 'fqdn')) {
|
||||||
|
try {
|
||||||
$firstFqdn = str($this->application->fqdn)->before(',');
|
$firstFqdn = str($this->application->fqdn)->before(',');
|
||||||
$url = Url::fromString($firstFqdn);
|
$url = Url::fromString($firstFqdn);
|
||||||
$host = $url->getHost();
|
$host = $url->getHost();
|
||||||
$this->preview_url_template = str($this->application->preview_url_template)->replace('{{domain}}', $host);
|
$this->preview_url_template = str($this->application->preview_url_template)->replace('{{domain}}', $host);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->dispatch('error', 'Invalid FQDN.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user