diff options
Diffstat (limited to 'src/api/routes/auth')
-rw-r--r-- | src/api/routes/auth/register.ts | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/api/routes/auth/register.ts b/src/api/routes/auth/register.ts index 09366a12..9c4f6050 100644 --- a/src/api/routes/auth/register.ts +++ b/src/api/routes/auth/register.ts @@ -1,5 +1,5 @@ import { Request, Response, Router } from "express"; -import { Config, generateToken, Invite, FieldErrors, User, adjustEmail, trimSpecial, RegisterSchema } from "@fosscord/util"; +import { Config, generateToken, Invite, FieldErrors, User, adjustEmail, RegisterSchema } from "@fosscord/util"; import { route, getIpAdress, IPAnalysis, isProxy } from "@fosscord/api"; import bcrypt from "bcrypt"; import { HTTPError } from "@fosscord/util"; @@ -37,6 +37,12 @@ router.post("/", route({ body: "RegisterSchema" }), async (req: Request, res: Re }); } + if (!register.allowGuests) { + throw FieldErrors({ + email: { code: "GUESTS_DISABLED", message: req.t("auth:register.GUESTS_DISABLED") } + }); + } + if (register.requireCaptcha && security.captcha.enabled) { if (!body.captcha_key) { const { sitekey, service } = security.captcha; @@ -97,7 +103,8 @@ router.post("/", route({ body: "RegisterSchema" }), async (req: Request, res: Re }); } - if (register.dateOfBirth.required && !body.date_of_birth) { + // If no password is provided, this is a guest account + if (register.dateOfBirth.required && (!body.date_of_birth && body.password)) { throw FieldErrors({ date_of_birth: { code: "BASE_TYPE_REQUIRED", message: req.t("common:field.BASE_TYPE_REQUIRED") } }); |