summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorngn <ngn13proton@proton.me>2023-06-10 20:51:21 +0300
committerngn <ngn13proton@proton.me>2023-06-10 20:51:21 +0300
commitf006ddc7354dd2248c6c480cced15617159fa62b (patch)
treed5b8876a9a7f1fff0cf8ebc639490384d0c61e3e /src/api
parentFix docs for /users/:id/profile (diff)
downloadserver-f006ddc7354dd2248c6c480cced15617159fa62b.tar.xz
Implemented password length check
Diffstat (limited to 'src/api')
-rw-r--r--src/api/routes/auth/register.ts8
1 files changed, 8 insertions, 0 deletions
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) {