1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-22 10:22:39 +01:00

made it prettier

This commit is contained in:
ngn 2023-06-11 15:17:03 +03:00
parent 41f14b3ad8
commit e774a9256b

View File

@ -225,15 +225,20 @@ router.post(
}
if (body.password) {
const min = register.password.minLength ? register.password.minLength : 8;
if(body.password.length < min){
throw FieldErrors({
password: {
code: "PASSWORD_REQUIREMENTS_MIN_LENGTH",
message: req.t("auth:register.PASSWORD_REQUIREMENTS_MIN_LENGTH", { min: min })
}
});
}
const min = register.password.minLength
? register.password.minLength
: 8;
if (body.password.length < min) {
throw FieldErrors({
password: {
code: "PASSWORD_REQUIREMENTS_MIN_LENGTH",
message: req.t(
"auth:register.PASSWORD_REQUIREMENTS_MIN_LENGTH",
{ min: min },
),
},
});
}
// the salt is saved in the password refer to bcrypt docs
body.password = await bcrypt.hash(body.password, 12);
} else if (register.password.required) {