diff options
| author | julian laplace <julescarbon@gmail.com> | 2023-06-12 17:52:27 +0200 |
|---|---|---|
| committer | julian laplace <julescarbon@gmail.com> | 2023-06-12 17:52:27 +0200 |
| commit | 0396aa163256d748897ba16d167e9c262233f49f (patch) | |
| tree | cb98bdaaeab8f978c1877684088e5081cd5b4a86 /bucky/util/auth.js | |
| parent | b7421b64be417819794a3fc1f8e938bb5d16a33a (diff) | |
fix newuser
Diffstat (limited to 'bucky/util/auth.js')
| -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) { |
