diff options
Diffstat (limited to 'bucky')
| -rw-r--r-- | bucky/util/auth.js | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/bucky/util/auth.js b/bucky/util/auth.js index 401ba6c..c4db277 100644 --- a/bucky/util/auth.js +++ b/bucky/util/auth.js @@ -44,13 +44,20 @@ var auth = (module.exports = { }, checkIfUserExists: function (req, res, next) { var username = util.sanitizeName(req.body.username); - db.getUserByUsername(username).then((user) => { - if (user) { - console.log(user); - return res.json({ error: "user exists" }); - } - next(); - }); + db.getUserByUsername(username) + .then((user) => { + if (user) { + console.log(user); + return res.json({ error: "user exists" }); + } + next(); + }) + .catch((error) => { + if (error.message === "EmptyResponse") { + return next(); + } + next(error); + }); }, createUser: function (req, res, next) { if (req.body.password !== req.body.password2) { |
