1
0
mirror of https://github.com/Foltik/Shimapan synced 2024-11-14 00:46:38 -05:00

Fix bug where user scope wouldn't be set in the JWT

This commit is contained in:
Jack 2017-10-13 16:16:26 -04:00
parent 95b0526858
commit aa615cd570
Signed by: foltik
GPG Key ID: 303F88F996E95541

View File

@ -36,27 +36,26 @@ function useInvite(code, username) {
router.post('/register', function(req, res) { router.post('/register', function(req, res) {
// Validate the parameters // Validate the parameters
async.parallel({ async.parallel({
username: function(callback) { userCheck: function(callback) {
checkUsername(req.body.username, function(err, valid) { checkUsername(req.body.username, function(err, valid) {
callback(err, valid); callback(err, valid);
}); });
}, },
invite: function(callback) { inviteCheck: function(callback) {
checkInvite(req.body.invite, function(err, valid, invite) { checkInvite(req.body.invite, function(err, valid, invite) {
callback(err, {valid: valid, invite: invite}); callback(err, {valid: valid, invite: invite});
}); });
} }
}, function(err, result) { }, function(err, result) {
if (!result.username) { if (!result.userCheck) {
res.status(401).json({'message': 'Username in use.'}); 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.'}); res.status(401).json({'message': 'Invalid invite code.'});
} else { } else {
useInvite(req.body.invite, req.body.username); useInvite(req.body.invite, req.body.username);
var user = new User(); var user = new User();
user.username = req.body.username; user.username = req.body.username;
user.scope = result.invite.scope; user.scope = result.inviteCheck.invite.scope;
user.date = new Date(); user.date = new Date();
user.setPassword(req.body.password); user.setPassword(req.body.password);