From 38e0acdefa04fe7bd5008146a715ee8b43bd73c9 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sun, 25 Sep 2022 11:14:05 +1000 Subject: [PATCH] Add discrim verify in PATCH /users/@me --- api/src/routes/users/@me/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/src/routes/users/@me/index.ts b/api/src/routes/users/@me/index.ts index dc0d1cb1..36b62b55 100644 --- a/api/src/routes/users/@me/index.ts +++ b/api/src/routes/users/@me/index.ts @@ -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();