1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-09 20:22:47 +01:00

Add discrim verify in PATCH /users/@me

This commit is contained in:
Madeline 2022-09-25 11:14:05 +10:00
parent 6fa18fdc89
commit 5b4d7dec35

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); user.assign(body);
await user.save(); await user.save();