diff --git a/routes/index.js b/routes/index.js index 6b5455f03e4..41f145a6f7a 100644 --- a/routes/index.js +++ b/routes/index.js @@ -35,8 +35,8 @@ exports.index = function (req, res, next) { }; exports.loginHandler = function (req, res, next) { - if (validator.isEmail(req.body.username)) { - User.find({ username: req.body.username, password: req.body.password }, function (err, users) { + if (typeof req.body.username === 'string' && typeof req.body.password === 'string' && validator.isEmail(req.body.username)) { + User.find({ username: { $eq: req.body.username }, password: { $eq: req.body.password } }, function (err, users) { if (users.length > 0) { const redirectPage = req.body.redirectPage const session = req.session