diff --git a/routes/index.js b/routes/index.js index 6b5455f03e4..1f92739ee95 100644 --- a/routes/index.js +++ b/routes/index.js @@ -35,8 +35,10 @@ 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) { + var username = typeof req.body.username === 'string' ? req.body.username : ''; + var password = typeof req.body.password === 'string' ? req.body.password : ''; + if (validator.isEmail(username)) { + User.find({ username: username, password: password }, function (err, users) { if (users.length > 0) { const redirectPage = req.body.redirectPage const session = req.session