summary refs log tree commit diff
path: root/src/api/routes/users/@me
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-27 03:54:58 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-27 03:58:16 +0200
commit204aa024dc61e47c13116d194fd6217b33687be5 (patch)
tree38f7579934ccb115b3ab509b61a75ccf6db09601 /src/api/routes/users/@me
parentMerge remote-tracking branch 'Maddy/fix/categoryNames' into staging (diff)
parentMerge remote-tracking branch 'upstream/staging' into fix/claim_accounts (diff)
downloadserver-204aa024dc61e47c13116d194fd6217b33687be5.tar.xz
Merge remote-tracking branch 'Maddy/fix/claim_accounts' into staging
Diffstat (limited to 'src/api/routes/users/@me')
-rw-r--r--src/api/routes/users/@me/index.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/api/routes/users/@me/index.ts b/src/api/routes/users/@me/index.ts

index fcb0a9df..563300dc 100644 --- a/src/api/routes/users/@me/index.ts +++ b/src/api/routes/users/@me/index.ts
@@ -1,5 +1,7 @@ import { route } from "@fosscord/api"; import { + adjustEmail, + Config, emitEvent, FieldErrors, generateToken, @@ -45,6 +47,13 @@ router.patch("/", route({ body: "UserModifySchema" }), async (req: Request, res: } } + if (body.email) { + body.email = adjustEmail(body.email); + if (!body.email && Config.get().register.email.required) + throw FieldErrors({ email: { message: req.t("auth:register.EMAIL_INVALID"), code: "EMAIL_INVALID" } }); + if (!body.password) throw FieldErrors({ password: { message: req.t("auth:register.INVALID_PASSWORD"), code: "INVALID_PASSWORD" } }); + } + if (body.new_password) { if (!body.password && !user.email) { throw FieldErrors({