fix registration flow

This commit is contained in:
Erik 2023-05-07 03:45:10 +03:00
parent 214e00d291
commit 175dea1877
Signed by: Navy.gif
GPG Key ID: 2532FBBB61C65A68
2 changed files with 9 additions and 7 deletions

View File

@ -17,7 +17,7 @@
"system"
],
"registrationEnabled": true,
"requireCodeForRegister": false,
"requireCodeForRegister": true,
"OAuthProviders": [
{
"name": "Discord",
@ -55,9 +55,10 @@
},
"logLevel": 0,
"logLevelMapping": {
"access": 3,
"unauthorised": 3
"access": 2,
"unauthorised": 2
},
"broadcastLevel": 3,
"webhook": {
"url": "https://discord.com/api/webhooks/1093874668886294548/uDMRD6g1lmq_2EZynsbKytzWoMM-0N4te0m61r_cv1BsSnDKDxG3fvI6sxSoG5t5b_xn"
}

View File

@ -52,11 +52,12 @@ class RegisterEndpoint extends ApiEndpoint {
if (existing)
return void res.status(400).send('Username taken');
if (this.#requireCodeForRegister) {
if (!code)
if (this.#requireCodeForRegister && !code) {
return void res.status(400).send('Registration code required for registration at this time');
} else if (code) {
// Consumes codes if given, but will only complain if the code is required
const codeCheck = await this.#userdb.consumeRegistrationCode(code);
if (!codeCheck)
if (!codeCheck && this.#requireCodeForRegister)
return void res.status(400).send('Invalid registration code');
}