From aa615cd5705fd0b79bf6281917a23555b61d1362 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 13 Oct 2017 16:16:26 -0400 Subject: [PATCH] Fix bug where user scope wouldn't be set in the JWT --- app/routes/auth.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/routes/auth.js b/app/routes/auth.js index 9b60714..6ce4546 100644 --- a/app/routes/auth.js +++ b/app/routes/auth.js @@ -36,27 +36,26 @@ function useInvite(code, username) { router.post('/register', function(req, res) { // Validate the parameters async.parallel({ - username: function(callback) { + userCheck: function(callback) { checkUsername(req.body.username, function(err, valid) { callback(err, valid); }); }, - invite: function(callback) { + inviteCheck: function(callback) { checkInvite(req.body.invite, function(err, valid, invite) { callback(err, {valid: valid, invite: invite}); }); } }, function(err, result) { - if (!result.username) { + if (!result.userCheck) { res.status(401).json({'message': 'Username in use.'}); - } else if (!result.invite.valid) { + } else if (!result.inviteCheck.valid) { res.status(401).json({'message': 'Invalid invite code.'}); } else { useInvite(req.body.invite, req.body.username); - var user = new User(); user.username = req.body.username; - user.scope = result.invite.scope; + user.scope = result.inviteCheck.invite.scope; user.date = new Date(); user.setPassword(req.body.password);