summary refs log tree commit diff
path: root/src/api/routes/auth
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-27 03:54:58 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-27 03:58:16 +0200
commit204aa024dc61e47c13116d194fd6217b33687be5 (patch)
tree38f7579934ccb115b3ab509b61a75ccf6db09601 /src/api/routes/auth
parentMerge remote-tracking branch 'Maddy/fix/categoryNames' into staging (diff)
parentMerge remote-tracking branch 'upstream/staging' into fix/claim_accounts (diff)
downloadserver-204aa024dc61e47c13116d194fd6217b33687be5.tar.xz
Merge remote-tracking branch 'Maddy/fix/claim_accounts' into staging
Diffstat (limited to 'src/api/routes/auth')
-rw-r--r--src/api/routes/auth/register.ts16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/api/routes/auth/register.ts b/src/api/routes/auth/register.ts
index d3b5a59c..5cc28f7a 100644
--- a/src/api/routes/auth/register.ts
+++ b/src/api/routes/auth/register.ts
@@ -1,6 +1,6 @@
+import { getIpAdress, IPAnalysis, isProxy, route, verifyCaptcha } from "@fosscord/api";
+import { adjustEmail, Config, FieldErrors, generateToken, HTTPError, Invite, RegisterSchema, User } from "@fosscord/util";
 import { Request, Response, Router } from "express";
-import { Config, generateToken, Invite, FieldErrors, User, adjustEmail, RegisterSchema } from "@fosscord/util";
-import { route, getIpAdress, IPAnalysis, isProxy, verifyCaptcha } from "@fosscord/api";
 
 let bcrypt: any;
 try {
@@ -9,7 +9,6 @@ try {
 	bcrypt = require("bcryptjs");
 	console.log("Warning: using bcryptjs because bcrypt is not installed! Performance will be affected.");
 }
-import { HTTPError } from "@fosscord/util";
 
 const router: Router = Router();
 
@@ -44,6 +43,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) {
 		const { sitekey, service } = security.captcha;
 		if (!body.captcha_key) {
@@ -60,7 +65,7 @@ router.post("/", route({ body: "RegisterSchema" }), async (req: Request, res: Re
 				captcha_key: verify["error-codes"],
 				captcha_sitekey: sitekey,
 				captcha_service: service
-			})
+			});
 		}
 	}
 
@@ -111,7 +116,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") }
 		});