1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-06 10:52:31 +01:00

[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
This commit is contained in:
RealMANI 2022-02-16 11:15:37 +03:30 committed by GitHub
parent f738d7d546
commit e8b24b3684
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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