checked for valid domain id

Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
tracer 2022-02-13 15:47:23 +01:00
parent 6c2d5ab8a0
commit 6ba728ac07
1 changed files with 19 additions and 10 deletions

View File

@ -328,17 +328,26 @@ class RequestController
if (empty($this->uri[3])) { if (empty($this->uri[3])) {
$this->handleAllDomainsGetRequest(); $this->handleAllDomainsGetRequest();
} else { } else {
if ($result = $this->domainRepository->findById(id: $this->uri[3])) { $id = intval(value: $this->uri['3']);
$domain = [ if ($id > 0) {
'id' => $result->getId(), if ($result = $this->domainRepository->findById(id: $id)) {
'name' => $result->getName(), $domain = [
'content' => json_decode(json: $result->getContent()) 'id' => $result->getId(),
]; 'name' => $result->getName(),
$this->result = $domain; 'content' => json_decode(json: $result->getContent())
];
$this->result = $domain;
} else {
$this->header = "404 Not Found ";
$this->status = "404 Not Found ";
$this->message = "The specified domain was not found.";
}
} else { } else {
$this->header = "404 Not Found "; $this->header = "400 Bad request";
$this->status = "404 Not Found "; $this->status = "400 Not Found";
$this->message = "The specified domain was not found."; $this->message = "You need to supply an ID or user the /domain/name/<name> path.";
} }
} }
} }