@@ -7568,6 +7568,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
75687568 $ usernameColumnName = $ this ->getProperty ('usernameColumn ' , 'username ' );
75697569 $ usernameColumn = $ table ->getColumn ($ usernameColumnName );
75707570 $ passwordColumnName = $ this ->getProperty ('passwordColumn ' , 'password ' );
7571+ $ passwordLength = $ this ->getProperty ('passwordLength ' , '12 ' );
75717572 $ pkName = $ table ->getPk ()->getName ();
75727573 $ registerUser = $ this ->getProperty ('registerUser ' , '' );
75737574 $ condition = new ColumnCondition ($ usernameColumn , 'eq ' , $ username );
@@ -7584,6 +7585,9 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
75847585 if (!$ registerUser ) {
75857586 return $ this ->responder ->error (ErrorCode::AUTHENTICATION_FAILED , $ username );
75867587 }
7588+ if (strlen ($ password ) < $ passwordLength ) {
7589+ return $ this ->responder ->error (ErrorCode::PASSWORD_TOO_SHORT , $ passwordLength );
7590+ }
75877591 $ users = $ this ->db ->selectAll ($ table , $ columnNames , $ condition , $ columnOrdering , 0 , 1 );
75887592 if (!empty ($ users )) {
75897593 return $ this ->responder ->error (ErrorCode::USER_ALREADY_EXIST , $ username );
@@ -7618,6 +7622,9 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
76187622 if ($ username != ($ _SESSION ['user ' ][$ usernameColumnName ] ?? '' )) {
76197623 return $ this ->responder ->error (ErrorCode::AUTHENTICATION_FAILED , $ username );
76207624 }
7625+ if (strlen ($ newPassword ) < $ passwordLength ) {
7626+ return $ this ->responder ->error (ErrorCode::PASSWORD_TOO_SHORT , $ passwordLength );
7627+ }
76217628 $ users = $ this ->db ->selectAll ($ table , $ columnNames , $ condition , $ columnOrdering , 0 , 1 );
76227629 foreach ($ users as $ user ) {
76237630 if (password_verify ($ password , $ user [$ passwordColumnName ]) == 1 ) {
@@ -9962,6 +9969,7 @@ class ErrorCode
99629969 const ONLY_AJAX_REQUESTS_ALLOWED = 1018 ;
99639970 const PAGINATION_FORBIDDEN = 1019 ;
99649971 const USER_ALREADY_EXIST = 1020 ;
9972+ const PASSWORD_TOO_SHORT = 1021 ;
99659973
99669974 private $ values = [
99679975 9999 => ["%s " , ResponseFactory::INTERNAL_SERVER_ERROR ],
@@ -9986,6 +9994,7 @@ class ErrorCode
99869994 1018 => ["Only AJAX requests allowed for '%s' " , ResponseFactory::FORBIDDEN ],
99879995 1019 => ["Pagination forbidden " , ResponseFactory::FORBIDDEN ],
99889996 1020 => ["User '%s' already exists " , ResponseFactory::CONFLICT ],
9997+ 1021 => ["Password too short (<%d characters) " , ResponseFactory::UNPROCESSABLE_ENTITY ],
99899998 ];
99909999
999110000 public function __construct (int $ code )
0 commit comments