Merge pull request #1069 from ngn13/pass_length_check
Implemented password length check
This commit is contained in:
commit
eb8a2513cf
@ -10,7 +10,8 @@
|
|||||||
"EMAIL_INVALID": "Invalid Email",
|
"EMAIL_INVALID": "Invalid Email",
|
||||||
"EMAIL_ALREADY_REGISTERED": "Email is already registered",
|
"EMAIL_ALREADY_REGISTERED": "Email is already registered",
|
||||||
"DATE_OF_BIRTH_UNDERAGE": "You need to be {{years}} years or older",
|
"DATE_OF_BIRTH_UNDERAGE": "You need to be {{years}} years or older",
|
||||||
"CONSENT_REQUIRED": "You must agree to the Terms of Service and Privacy Policy.",
|
"PASSWORD_REQUIREMENTS_MIN_LENGTH": "Must be at least {{min}} characters long.",
|
||||||
|
"CONSENT_REQUIRED": "You must agree to the Terms of Service and Privacy Policy.",
|
||||||
"USERNAME_TOO_MANY_USERS": "Too many users have this username, please try another"
|
"USERNAME_TOO_MANY_USERS": "Too many users have this username, please try another"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,6 +225,20 @@ router.post(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (body.password) {
|
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 },
|
||||||
|
),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
// the salt is saved in the password refer to bcrypt docs
|
// the salt is saved in the password refer to bcrypt docs
|
||||||
body.password = await bcrypt.hash(body.password, 12);
|
body.password = await bcrypt.hash(body.password, 12);
|
||||||
} else if (register.password.required) {
|
} else if (register.password.required) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user