fix: return an error on username change with no password

This commit is contained in:
Cyber 2024-07-21 20:00:14 +02:00 committed by Madeline
parent 481cf38373
commit b682f170b9

View File

@ -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({