summary refs log tree commit diff
path: root/api
diff options
context:
space:
mode:
authorRealMANI <96433859+ImAaronFR@users.noreply.github.com>2022-02-16 11:15:37 +0330
committerGitHub <noreply@github.com>2022-02-16 10:45:37 +0300
commite8b24b368435eec1c2ab9c0e4cebb5d0170fdb08 (patch)
tree61d188fe1b981d4d102be73b30e9e84fecfbdbfe /api
parentBump follow-redirects from 1.14.6 to 1.14.8 in /cdn (#635) (diff)
downloadserver-e8b24b368435eec1c2ab9c0e4cebb5d0170fdb08.tar.xz
[Fix] Invisible space username (#639)
You can send only spaces to the server and have a invisible username, this way you can remove the spaces and check and if it wasn't null after you know it's not just spaces
Diffstat (limited to 'api')
-rw-r--r--api/src/routes/users/@me/index.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/api/src/routes/users/@me/index.ts b/api/src/routes/users/@me/index.ts
index 1959704a..acca8910 100644
--- a/api/src/routes/users/@me/index.ts
+++ b/api/src/routes/users/@me/index.ts
@@ -57,6 +57,13 @@ router.patch("/", route({ body: "UserModifySchema" }), async (req: Request, res:
 		user.data.hash = await bcrypt.hash(body.new_password, 12);
 	}
 
+	var check_username = body?.username?.replace(/\s/g, '');
+	if(!check_username) {
+		throw FieldErrors({
+			username: { code: "BASE_TYPE_REQUIRED", message: req.t("common:field.BASE_TYPE_REQUIRED") }
+		});
+	}
+
 	await user.save();
 
 	// @ts-ignore