From 2950294c6da28bfd2048b335d3191dc5cf2861ca Mon Sep 17 00:00:00 2001 From: holabayor <39333226+holabayor@users.noreply.github.com> Date: Mon, 25 Sep 2023 19:43:49 +0100 Subject: [PATCH] Update lunchControllers.js --- controllers/lunchControllers.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/controllers/lunchControllers.js b/controllers/lunchControllers.js index 45930526..e7f29399 100644 --- a/controllers/lunchControllers.js +++ b/controllers/lunchControllers.js @@ -63,6 +63,10 @@ const sendLunch = async (req, res) => { User.findOne({ where: { id: receiver_id } }), ]); + if (!receiver) { + return createCustomError('Receiver not found', 404); + } + // Check if the sender has enough balance if ( sender.lunch_credit_balance < totalLunchPrice ||