From 8f93bea0abf0e21cd687cad5f210f066b3c65e6c Mon Sep 17 00:00:00 2001 From: Nevil Date: Thu, 14 Mar 2024 15:10:57 +0530 Subject: [PATCH 1/2] updated seats_remaining check --- src/services/sessions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/sessions.js b/src/services/sessions.js index 4f922d736..d6a6de908 100644 --- a/src/services/sessions.js +++ b/src/services/sessions.js @@ -1145,7 +1145,7 @@ module.exports = class SessionsHelper { }) } - if (session.seats_remaining <= 0) { + if (session.seats_remaining <= 0 && session.created_by != userId) { return responses.failureResponse({ message: 'SESSION_SEAT_FULL', statusCode: httpStatusCode.bad_request, From f9054182536aad1cd9466c38edaa85440cd8ae50 Mon Sep 17 00:00:00 2001 From: sumanvpacewisdom Date: Thu, 14 Mar 2024 16:27:16 +0530 Subject: [PATCH 2/2] Improper Type Validation --- src/controllers/v1/sessions.js | 2 +- src/middlewares/pagination.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/controllers/v1/sessions.js b/src/controllers/v1/sessions.js index e81b978bc..92b0a51bf 100644 --- a/src/controllers/v1/sessions.js +++ b/src/controllers/v1/sessions.js @@ -26,7 +26,7 @@ module.exports = class Sessions { async update(req) { try { // check if notifyUser is true or false. By default true - const notifyUser = req.query.notifyUser ? req.query.notifyUser.toLowerCase() === 'true' : true + const notifyUser = req.query.notifyUser ? String(req.query.notifyUser).toLowerCase() === 'true' : true if (req.params.id) { if (req.headers.timezone) { diff --git a/src/middlewares/pagination.js b/src/middlewares/pagination.js index 3219344d8..e91571086 100644 --- a/src/middlewares/pagination.js +++ b/src/middlewares/pagination.js @@ -12,10 +12,12 @@ function containsSpecialChars(str) { } module.exports = (req, res, next) => { + const searchData = req.query.search req.pageNo = req.query.page && Number(req.query.page) > 0 ? Number(req.query.page) : 1 req.pageSize = req.query.limit && Number(req.query.limit) > 0 && Number(req.query.limit) <= 100 ? Number(req.query.limit) : 100 - req.searchText = req.query.search && req.query.search != '' ? decodeURI(req.query.search) : '' + req.searchText = + searchData && typeof searchData === 'string' && searchData.trim() !== '' ? decodeURI(searchData) : '' if (req.searchText != '') { let buff = new Buffer.from(req.searchText, 'base64') req.searchText = buff.toString('ascii')