diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-09-25 11:14:05 +1000 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-09-25 11:14:05 +1000 |
commit | 5b4d7dec35362db510e1f3c635009ae8f8fd51b0 (patch) | |
tree | 2765eded82154e192cc41b38a1975f8f84f1a601 | |
parent | Typeorm doesn't even use the cache for BaseEntity.* methods (diff) | |
download | server-5b4d7dec35362db510e1f3c635009ae8f8fd51b0.tar.xz |
Add discrim verify in PATCH /users/@me
-rw-r--r-- | api/src/routes/users/@me/index.ts | 8 |
1 files changed, 8 insertions, 0 deletions
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(); |