diff --git a/routes/index.js b/routes/index.js index 6b5455f03e4..745c7e69b24 100644 --- a/routes/index.js +++ b/routes/index.js @@ -35,8 +35,12 @@ exports.index = function (req, res, next) { }; exports.loginHandler = function (req, res, next) { + if (typeof req.body.username !== 'string' || typeof req.body.password !== 'string') { + return res.status(401).send() + } + if (validator.isEmail(req.body.username)) { - User.find({ username: req.body.username, password: req.body.password }, function (err, users) { + User.find({ username: String(req.body.username), password: String(req.body.password) }, function (err, users) { if (users.length > 0) { const redirectPage = req.body.redirectPage const session = req.session