Fix a bug checking the validity of invite codes

merge-requests/26/head
knotteye 2020-10-13 16:29:13 -05:00
parent acce235812
commit 1a410a597a
1 changed files with 12 additions and 10 deletions

View File

@ -225,7 +225,8 @@ async function initAPI() {
}); });
app.post('/api/register', (req, res) => { app.post('/api/register', (req, res) => {
if("invite" in req.body){ if("invite" in req.body){
if(api.validInvite(req.body.invite)){ api.validInvite(req.body.invite).then((v) => {
if(v){
api.register(req.body.username, req.body.password, req.body.confirm, true).then((result) => { api.register(req.body.username, req.body.password, req.body.confirm, true).then((result) => {
if(result[0]) return genToken(req.body.username).then((t) => { if(result[0]) return genToken(req.body.username).then((t) => {
res.cookie('Authorization', t, {maxAge: 604800000, httpOnly: true, sameSite: 'Lax'}); res.cookie('Authorization', t, {maxAge: 604800000, httpOnly: true, sameSite: 'Lax'});
@ -237,6 +238,7 @@ async function initAPI() {
}); });
} }
else res.json({error: "invalid invite code"}); else res.json({error: "invalid invite code"});
});
} }
else else
api.register(req.body.username, req.body.password, req.body.confirm).then( (result) => { api.register(req.body.username, req.body.password, req.body.confirm).then( (result) => {