Skip to content

Commit

Permalink
added server side check
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip10 committed Dec 4, 2024
1 parent ab52b1d commit 18b2463
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions App/Controllers/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,20 @@ public function add(): Response
{
$post = new Post(); // toto je pre nový post
$post->setAutor($this->app->getAuth()->getLoggedUserName());
$post->setNazov($this->request()->getValue('nazov'));
$post->setPopis($this->request()->getValue('popis'));
$post->setDatumPublikovania($this->request()->getValue('date'));

$nazov = $this->request()->getValue('nazov');
$popis = $this->request()->getValue('popis');
$date = $this->request()->getValue('date');
$urlInput = (string)($this->request()->getValue('url'));

if (empty($nazov) || empty($popis) || empty($date) || empty($urlInput)) {
// Handle the error, e.g., return an error response or show a message
throw new Exception("Všetky polia je potrebné vyplniť!");
}

$post->setNazov($nazov);
$post->setPopis($popis);
$post->setDatumPublikovania($date);
$post->setZdroj($urlInput);

$post->save();
Expand Down

0 comments on commit 18b2463

Please sign in to comment.