From f2499167e4e2205057860c74055dd943cd180789 Mon Sep 17 00:00:00 2001 From: Cyber Date: Sun, 21 Jul 2024 20:00:14 +0200 Subject: [PATCH] fix: return an error on username change with no password --- src/api/routes/users/@me/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/api/routes/users/@me/index.ts b/src/api/routes/users/@me/index.ts index ad11a4281..95f572af8 100644 --- a/src/api/routes/users/@me/index.ts +++ b/src/api/routes/users/@me/index.ts @@ -120,7 +120,7 @@ router.patch( if (!body.password) throw FieldErrors({ password: { - message: req.t("auth:register.INVALID_PASSWORD"), + message: req.t("auth:login.INVALID_PASSWORD"), code: "INVALID_PASSWORD", }, }); @@ -162,6 +162,15 @@ router.patch( } } + if (!body.password) { + throw FieldErrors({ + password: { + message: req.t("auth:login.INVALID_PASSWORD"), + code: "INVALID_PASSWORD", + }, + }); + } + if (body.discriminator) { if ( await User.findOne({