get post params with Utils::getOrDie()

This commit is contained in:
Thomas Rubini 2023-01-25 21:57:34 +01:00
parent 81e67a0bf5
commit 00c103fdd3
No known key found for this signature in database
GPG Key ID: C7D287C8C1CAC373

View File

@ -55,13 +55,15 @@ final class RecipeController
{
Session::login_or_die();
$O_difficulty = DifficultyModel::getByName($A_postParams["recipeDifficulty"]);
$O_difficulty = DifficultyModel::getByName(Utils::getOrDie($A_postParams, "recipeDifficulty"));
if($O_difficulty === null){
throw new HTTPSpecialCaseException(400, "Invalid difficulty");
}
$O_recipe = new RecipeModel(
$A_postParams["recipeName"], $A_postParams["recipeTime"], $A_postParams["recipeDescription"],
Utils::getOrDie($A_postParams, "recipeName"),
Utils::getOrDie($A_postParams, "recipeTime"),
Utils::getOrDie($A_postParams, "recipeDescription"),
null, $O_difficulty->I_ID, $_SESSION["ID"]
);
$O_recipe->insert();