summary refs log tree commit diff
path: root/src/api/routes/users/@me/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/routes/users/@me/index.ts')
-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({