From 43877820cfdb73e0c2986f51fcaacf55fc932fd1 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Mon, 28 Oct 2019 10:38:31 +0100 Subject: [PATCH] validate real estate type selection --- app/controllers/realEstateTypes.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/realEstateTypes.js b/app/controllers/realEstateTypes.js index f021f04..d1a6411 100644 --- a/app/controllers/realEstateTypes.js +++ b/app/controllers/realEstateTypes.js @@ -15,8 +15,15 @@ const getRealEstateTypes = (req, res) => { const postRealEstateTypes = async (req, res) => { const searchRequest = await currentSearchRequest(req); - //TODO: check if selected real estate type is valid + const validRealEstateTypes = Object.keys(AD_CATEGORY).filter( + category => !!AD_CATEGORY[category].title + ); + const selectedRealEstateType = req.body.realEstateType || null; + if (validRealEstateTypes.indexOf(selectedRealEstateType) === -1) { + res.render("notFound", { title: " " }); + return; + } const nextStepPage = req.query.nextStep || "lokacija";