summary refs log tree commit diff
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-07-08 22:45:10 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-07-08 22:45:10 +1000
commitc103ac4a96711c29dad83d55b25ce0b225d509f8 (patch)
treec5194da5accda2ab40fda8d13797c3de577b2292
parentMerge branch 'master' into fix/claim_accounts (diff)
downloadserver-c103ac4a96711c29dad83d55b25ce0b225d509f8.tar.xz
Check if email required in PATCH @me
-rw-r--r--api/src/routes/users/@me/index.ts6
1 files changed, 3 insertions, 3 deletions
diff --git a/api/src/routes/users/@me/index.ts b/api/src/routes/users/@me/index.ts
index b42a00b2..c3f6bfe0 100644
--- a/api/src/routes/users/@me/index.ts
+++ b/api/src/routes/users/@me/index.ts
@@ -1,5 +1,5 @@
 import { Router, Request, Response } from "express";
-import { User, PrivateUserProjection, emitEvent, UserUpdateEvent, handleFile, FieldErrors, adjustEmail } from "@fosscord/util";
+import { User, PrivateUserProjection, emitEvent, UserUpdateEvent, handleFile, FieldErrors, adjustEmail, Config } from "@fosscord/util";
 import { route } from "@fosscord/api";
 import bcrypt from "bcrypt";
 
@@ -49,10 +49,10 @@ router.patch("/", route({ body: "UserModifySchema" }), async (req: Request, res:
 
 	if (body.email) {
 		body.email = adjustEmail(body.email);
-		if (!body.email)
+		if (!body.email && Config.get().register.email.required)
 			throw FieldErrors({ email: { message: req.t("auth:register.EMAIL_INVALID"), code: "EMAIL_INVALID" } });
 		if (!body.password)
-			throw FieldErrors({ password: { message: req.t("auth:register.INVALID_PASSWORD"), code: "INVALID_PASSWORD" } })
+			throw FieldErrors({ password: { message: req.t("auth:register.INVALID_PASSWORD"), code: "INVALID_PASSWORD" } });
 	}
 
 	if (body.new_password) {