added error check on domain creation
Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
parent
8f2545dd7e
commit
f1732c4f26
|
@ -361,14 +361,14 @@ class RequestController
|
||||||
function handleDomainPostRequest(): void
|
function handleDomainPostRequest(): void
|
||||||
{
|
{
|
||||||
$name = $_POST['name'] ?? '';
|
$name = $_POST['name'] ?? '';
|
||||||
$panelID = intval(value: $_POST['panel_id'] ?? 0);
|
$panel = $_POST['panel'] ?? '';
|
||||||
$content = $_POST['content'] ?? '';
|
$content = $_POST['content'] ?? '';
|
||||||
if (empty($name)) {
|
if (empty($name)) {
|
||||||
$this->header = "400 Bad Request";
|
$this->header = "400 Bad Request";
|
||||||
$this->status = "400 Bad Request";
|
$this->status = "400 Bad Request";
|
||||||
$this->message = "A name is required";
|
$this->message = "A name is required";
|
||||||
} else {
|
} else {
|
||||||
if (empty($a) && empty($aaaa) && empty($panelID)) {
|
if (empty($a) && empty($aaaa) && empty($panel)) {
|
||||||
$this->header = "400 Bad Request";
|
$this->header = "400 Bad Request";
|
||||||
$this->status = "400 Bad Request";
|
$this->status = "400 Bad Request";
|
||||||
$this->message = "At least one IP address or panel ID is required.";
|
$this->message = "At least one IP address or panel ID is required.";
|
||||||
|
@ -379,9 +379,14 @@ class RequestController
|
||||||
$this->message = "Domain: $name already exists.";
|
$this->message = "Domain: $name already exists.";
|
||||||
} else {
|
} else {
|
||||||
$domain = new Domain(name: $name, content: $content);
|
$domain = new Domain(name: $name, content: $content);
|
||||||
$result = $this->domainRepository->insert(domain: $domain);
|
if ($result = $this->domainRepository->insert(domain: $domain)) {
|
||||||
$this->status = "201 Created";
|
$this->status = "201 Created";
|
||||||
$this->message = $result;
|
$this->message = $result;
|
||||||
|
} else {
|
||||||
|
$this->header = "500 Server error";
|
||||||
|
$this->status = "500 Server error";
|
||||||
|
$this->message = $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue