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:
parent
e67f261f9a
commit
38e0acdefa
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user