Fix a bug checking the validity of invite codes
parent
acce235812
commit
1a410a597a
22
src/http.ts
22
src/http.ts
|
@ -225,18 +225,20 @@ 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) => {
|
||||||
api.register(req.body.username, req.body.password, req.body.confirm, true).then((result) => {
|
if(v){
|
||||||
if(result[0]) return genToken(req.body.username).then((t) => {
|
api.register(req.body.username, req.body.password, req.body.confirm, true).then((result) => {
|
||||||
res.cookie('Authorization', t, {maxAge: 604800000, httpOnly: true, sameSite: 'Lax'});
|
if(result[0]) return genToken(req.body.username).then((t) => {
|
||||||
|
res.cookie('Authorization', t, {maxAge: 604800000, httpOnly: true, sameSite: 'Lax'});
|
||||||
|
res.json(result);
|
||||||
|
api.useInvite(req.body.invite);
|
||||||
|
return;
|
||||||
|
});
|
||||||
res.json(result);
|
res.json(result);
|
||||||
api.useInvite(req.body.invite);
|
|
||||||
return;
|
|
||||||
});
|
});
|
||||||
res.json(result);
|
}
|
||||||
});
|
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) => {
|
||||||
|
|
Reference in New Issue