From e6a44bcb0e6a3c154c55f222ae4d0d34ecabebfd Mon Sep 17 00:00:00 2001 From: David Carlin Date: Mon, 11 May 2020 08:30:23 +1000 Subject: [PATCH] Validate next parameter to ensure it's a function --- lib/middleware/authenticate.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/middleware/authenticate.js b/lib/middleware/authenticate.js index dc70cfc2..6682b1da 100644 --- a/lib/middleware/authenticate.js +++ b/lib/middleware/authenticate.js @@ -92,6 +92,9 @@ module.exports = function authenticate(passport, name, options, callback) { } return function authenticate(req, res, next) { + if (typeof next !== 'function') { + throw 'TypeError: next is not a function. authenticate function requires (req, res, next)'; + } if (http.IncomingMessage.prototype.logIn && http.IncomingMessage.prototype.logIn !== IncomingMessageExt.logIn) { require('../framework/connect').__monkeypatchNode();