diff options
author | ngn <ngn13proton@proton.me> | 2023-06-10 20:51:21 +0300 |
---|---|---|
committer | ngn <ngn13proton@proton.me> | 2023-06-10 20:51:21 +0300 |
commit | f006ddc7354dd2248c6c480cced15617159fa62b (patch) | |
tree | d5b8876a9a7f1fff0cf8ebc639490384d0c61e3e | |
parent | Fix docs for /users/:id/profile (diff) | |
download | server-f006ddc7354dd2248c6c480cced15617159fa62b.tar.xz |
Implemented password length check
-rw-r--r-- | assets/locales/ur/auth.json | 3 | ||||
-rw-r--r-- | src/api/routes/auth/register.ts | 8 |
2 files changed, 10 insertions, 1 deletions
diff --git a/assets/locales/ur/auth.json b/assets/locales/ur/auth.json index e19547a0..ed7dc26d 100644 --- a/assets/locales/ur/auth.json +++ b/assets/locales/ur/auth.json @@ -10,7 +10,8 @@ "EMAIL_INVALID": "Invalid Email", "EMAIL_ALREADY_REGISTERED": "Email is already registered", "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 8 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" } } diff --git a/src/api/routes/auth/register.ts b/src/api/routes/auth/register.ts index 321b4a65..7b62f621 100644 --- a/src/api/routes/auth/register.ts +++ b/src/api/routes/auth/register.ts @@ -225,6 +225,14 @@ router.post( } if (body.password) { + if(body.password.length<8){ + throw FieldErrors({ + password: { + code: "PASSWORD_REQUIREMENTS_MIN_LENGTH", + message: req.t("auth:register.PASSWORD_REQUIREMENTS_MIN_LENGTH") + } + }); + } // the salt is saved in the password refer to bcrypt docs body.password = await bcrypt.hash(body.password, 12); } else if (register.password.required) { |