summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-06-11 22:27:33 +1000
committerGitHub <noreply@github.com>2023-06-11 22:27:33 +1000
commiteb8a2513cf9ed7cbbdd8e2c166b2c2b3f04b7fe9 (patch)
tree8b13c6c298e3aecf2d4964a618b361bbafe53810 /src
parentMerge pull request #1068 from V3L0C1T13S/feat/gen_memberlist_id (diff)
parentmade it prettier (diff)
downloadserver-eb8a2513cf9ed7cbbdd8e2c166b2c2b3f04b7fe9.tar.xz
Merge pull request #1069 from ngn13/pass_length_check
Implemented password length check
Diffstat (limited to 'src')
-rw-r--r--src/api/routes/auth/register.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/api/routes/auth/register.ts b/src/api/routes/auth/register.ts
index 321b4a65..14dc319a 100644
--- a/src/api/routes/auth/register.ts
+++ b/src/api/routes/auth/register.ts
@@ -225,6 +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 },
+						),
+					},
+				});
+			}
 			// the salt is saved in the password refer to bcrypt docs
 			body.password = await bcrypt.hash(body.password, 12);
 		} else if (register.password.required) {