From f006ddc7354dd2248c6c480cced15617159fa62b Mon Sep 17 00:00:00 2001 From: ngn Date: Sat, 10 Jun 2023 20:51:21 +0300 Subject: Implemented password length check --- src/api/routes/auth/register.ts | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') 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) { -- cgit 1.4.1