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:
parent
f738d7d546
commit
e8b24b3684
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user