summary refs log tree commit diff
path: root/src/api/routes/auth
diff options
context:
space:
mode:
authorPuyodead1 <puyodead@protonmail.com>2023-02-24 06:36:57 -0500
committerPuyodead1 <puyodead@protonmail.com>2023-02-24 06:36:57 -0500
commited38d74b3e994f4bd7be5ac22fb167f4169c77a3 (patch)
tree27edc1392e7e4bc18fc02f57e5a8ae7e58ac5bc1 /src/api/routes/auth
parentimplement password reset (diff)
downloadserver-ed38d74b3e994f4bd7be5ac22fb167f4169c77a3.tar.xz
don't return token on register if verification required
Diffstat (limited to 'src/api/routes/auth')
-rw-r--r--src/api/routes/auth/register.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/api/routes/auth/register.ts b/src/api/routes/auth/register.ts
index 0bf8efae..c941fdf6 100644
--- a/src/api/routes/auth/register.ts
+++ b/src/api/routes/auth/register.ts
@@ -278,6 +278,17 @@ router.post(
 			await Invite.joinGuild(user.id, body.invite);
 		}
 
+		// return an error for unverified accounts if verification is required
+		if (Config.get().login.requireVerification && !user.verified) {
+			throw FieldErrors({
+				login: {
+					code: "ACCOUNT_LOGIN_VERIFICATION_EMAIL",
+					message:
+						"Email verification is required, please check your email.",
+				},
+			});
+		}
+
 		return res.json({ token: await generateToken(user.id) });
 	},
 );