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();