Shun Miyazawa 1 год назад
Родитель
Сommit
9a941c10c6

+ 0 - 1
apps/app/src/consts/user.ts

@@ -1 +0,0 @@
-export const DEFAULT_PASSOWRD_MINIMUM_NUMBER = 8;

+ 3 - 7
apps/app/src/server/middlewares/login-form-validator.ts

@@ -1,11 +1,7 @@
 import { ErrorV3 } from '@growi/core/dist/models';
 import { ErrorV3 } from '@growi/core/dist/models';
 import { body, validationResult, type ValidationChain } from 'express-validator';
 import { body, validationResult, type ValidationChain } from 'express-validator';
-
-import { DEFAULT_PASSOWRD_MINIMUM_NUMBER } from '~/consts/user';
-
 // form rules
 // form rules
-export const loginRules = (minPasswordLength?: number): ValidationChain[] => {
-  const fixedMinPasswordLength = minPasswordLength ?? DEFAULT_PASSOWRD_MINIMUM_NUMBER;
+export const loginRules = (minPasswordLength: number): ValidationChain[] => {
 
 
   return [
   return [
     body('loginForm.username')
     body('loginForm.username')
@@ -17,8 +13,8 @@ export const loginRules = (minPasswordLength?: number): ValidationChain[] => {
     body('loginForm.password')
     body('loginForm.password')
       .matches(/^[\x20-\x7F]*$/)
       .matches(/^[\x20-\x7F]*$/)
       .withMessage('message.Password has invalid character')
       .withMessage('message.Password has invalid character')
-      .isLength({ min: fixedMinPasswordLength })
-      .withMessage(new ErrorV3('message.Password minimum character should be more than n characters', undefined, undefined, { number: fixedMinPasswordLength }))
+      .isLength({ min: minPasswordLength })
+      .withMessage(new ErrorV3('message.Password minimum character should be more than n characters', undefined, undefined, { number: minPasswordLength }))
       .not()
       .not()
       .isEmpty()
       .isEmpty()
       .withMessage('message.Password field is required'),
       .withMessage('message.Password field is required'),

+ 3 - 7
apps/app/src/server/middlewares/register-form-validator.ts

@@ -1,12 +1,8 @@
 import { ErrorV3 } from '@growi/core/dist/models';
 import { ErrorV3 } from '@growi/core/dist/models';
 import { body, validationResult, type ValidationChain } from 'express-validator';
 import { body, validationResult, type ValidationChain } from 'express-validator';
 
 
-import { DEFAULT_PASSOWRD_MINIMUM_NUMBER } from '~/consts/user';
-
 // form rules
 // form rules
-export const registerRules = (minPasswordLength?: number): ValidationChain[] => {
-  const fixedMinPasswordLength = minPasswordLength ?? DEFAULT_PASSOWRD_MINIMUM_NUMBER;
-
+export const registerRules = (minPasswordLength: number): ValidationChain[] => {
   return [
   return [
     body('registerForm.username')
     body('registerForm.username')
       .matches(/^[\da-zA-Z\-_.]+$/)
       .matches(/^[\da-zA-Z\-_.]+$/)
@@ -23,8 +19,8 @@ export const registerRules = (minPasswordLength?: number): ValidationChain[] =>
     body('registerForm.password')
     body('registerForm.password')
       .matches(/^[\x20-\x7F]*$/)
       .matches(/^[\x20-\x7F]*$/)
       .withMessage('message.Password has invalid character')
       .withMessage('message.Password has invalid character')
-      .isLength({ min: fixedMinPasswordLength })
-      .withMessage(new ErrorV3('message.Password minimum character should be more than n characters', undefined, undefined, { number: fixedMinPasswordLength }))
+      .isLength({ min: minPasswordLength })
+      .withMessage(new ErrorV3('message.Password minimum character should be more than n characters', undefined, undefined, { number: minPasswordLength }))
       .not()
       .not()
       .isEmpty()
       .isEmpty()
       .withMessage('message.Password field is required'),
       .withMessage('message.Password field is required'),