]> git.agnieray.net Git - galette.git/commitdiff
Makes default member password stronger
authorJohan Cwiklinski <johan@x-tnd.be>
Mon, 17 Aug 2020 06:20:34 +0000 (08:20 +0200)
committerJohan Cwiklinski <johan@x-tnd.be>
Mon, 17 Aug 2020 08:12:03 +0000 (10:12 +0200)
galette/lib/Galette/Controllers/Crud/MembersController.php
galette/lib/Galette/Core/AbstractPassword.php
galette/lib/Galette/Core/Password.php

index a36ad59cb955d1acb4983646f400cadaa465551a..43df6eb7380db4e7415238f686a04cd958f1c78c 100644 (file)
@@ -1883,7 +1883,7 @@ class MembersController extends CrudController
                 }
             }
 
-            if (count($error_detected) == 0) {
+            if (count($error_detected) === 0) {
                 $files_res = $member->handleFiles($_FILES);
                 if (is_array($files_res)) {
                     $error_detected = array_merge($error_detected, $files_res);
@@ -1936,7 +1936,7 @@ class MembersController extends CrudController
                 }
             }
 
-            if (count($error_detected) == 0) {
+            if (count($error_detected) === 0) {
                 if (isset($args['self'])) {
                     $redirect_url = $this->router->pathFor('login');
                 } elseif (
index 9334c6463fa10c8a7d84673c1cb0dfca7a756174..2bccc2ed5506f6b135f8e3693b150f1f302d19a3 100644 (file)
@@ -81,12 +81,12 @@ abstract class AbstractPassword
             || trim($size) == ''
             || !is_int($size)
         ) {
-            $size = self::DEFAULT_SIZE;
+            $size = static::DEFAULT_SIZE;
         }
         $pass = '';
         $i = 0;
         while ($i <= $size - 1) {
-            $num = mt_rand(0, 32) % 33;
+            $num = mt_rand(0, strlen($this->chars) - 1)  % strlen($this->chars);
             $pass .= substr($this->chars, $num, 1);
             $i++;
         }
index 74cd7552a108a7d7dfca3a7fc29580e11b285c89..b024fc9e9630bf52c6d086882608f75d2edf5891 100644 (file)
@@ -62,6 +62,11 @@ class Password extends AbstractPassword
     public const TABLE = 'tmppasswds';
     public const PK = Adherent::PK;
 
+    /** @var integer Overrides default password size */
+    public const DEFAULT_SIZE = 50;
+    /** @var string Overrides default character set */
+    protected $chars = 'abcdefghjkmnpqrstuvwxyz0123456789&@{[]}%#+*:ABCDEFGHIJKLMNOPQRSTUVWXYZ';
+
     private $zdb;
 
     /**