From b682f170b9e6156d7db66fc1527f451b734300db 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 ad11a428..95f572af 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({