After testing the code, I found that when you run a check on a username that does not exist. The server times out and does not send the proper response back to the client. The code:
exports.check = function(req, res) {
Users.findOne({ login: req.params.login }, function(err, acc) {
if (err)
res.send(err);
if (acc == null){return res.status(401);
res.json({'Reply-Message': 'Login invalid'});}
res.set('Content-Type', 'application/json');
res.sendStatus(204);
});
};
After testing the code, I found that when you run a check on a username that does not exist. The server times out and does not send the proper response back to the client. The code: exports.check = function(req, res) { Users.findOne({ login: req.params.login }, function(err, acc) { if (err) res.send(err); if (acc == null){return res.status(401); res.json({'Reply-Message': 'Login invalid'});} res.set('Content-Type', 'application/json'); res.sendStatus(204); }); };
The bug lies inside the second if statement.