summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorngn <ngn13proton@proton.me>2023-06-11 15:17:03 +0300
committerngn <ngn13proton@proton.me>2023-06-11 15:17:03 +0300
commite774a9256bddba054f1cd030fc9d65e4ec1d2c23 (patch)
tree8b13c6c298e3aecf2d4964a618b361bbafe53810 /src
parentMake sure min password length is not null (diff)
downloadserver-e774a9256bddba054f1cd030fc9d65e4ec1d2c23.tar.xz
made it prettier
Diffstat (limited to 'src')
-rw-r--r--src/api/routes/auth/register.ts23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/api/routes/auth/register.ts b/src/api/routes/auth/register.ts
index 46026d7d..14dc319a 100644
--- a/src/api/routes/auth/register.ts
+++ b/src/api/routes/auth/register.ts
@@ -225,15 +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 })
-                                        }
-                                });
-                        }
+			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) {