1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-10 04:32:35 +01:00

Add discrim verify in PATCH /users/@me

This commit is contained in:
Madeline 2022-09-25 11:14:05 +10:00
parent e67f261f9a
commit 38e0acdefa
No known key found for this signature in database
GPG Key ID: 80D25DA3BCB24281

View File

@ -77,6 +77,14 @@ router.patch("/", route({ body: "UserModifySchema" }), async (req: Request, res:
}
}
if (body.discriminator) {
if (await User.findOne({ where: { discriminator: body.discriminator, username: body.username || user.username } })) {
throw FieldErrors({
discriminator: { code: "INVALID_DISCRIMINATOR", message: "This discriminator is already in use." }
});
}
}
user.assign(body);
await user.save();