]> git.agnieray.net Git - galette.git/commitdiff
Add new text for disabled accounts, send on password recovery request
authorJohan Cwiklinski <johan@x-tnd.be>
Sat, 19 Dec 2020 23:47:30 +0000 (00:47 +0100)
committerJohan Cwiklinski <johan@x-tnd.be>
Thu, 24 Dec 2020 06:27:25 +0000 (07:27 +0100)
closes #1529

galette/includes/fields_defs/texts_fields.php
galette/lib/Galette/Controllers/AuthController.php
tests/Galette/Entity/tests/units/Texts.php

index 34b6279109af2b6259c6bd53f7e18edaa666bbc0..c4412423d39c4818488d9c7cdb553b52307bc2d7 100644 (file)
@@ -130,4 +130,12 @@ $texts_fields = array(
         'tlang'     => 'en_US',
         'tcomment'  => _T('Informs admin a member edit his information')
     ),
+
+    array(
+        'tref'      => 'pwddisabled',
+        'tsubject'  => _T('[{ASSO_NAME}] Account {NAME_ADH} is inactive'),
+        'tbody'     => _T("Hello!{NEWLINE}A password recovery request has been made on your account on {ASSO_NAME}, but it is currently inactive and therefore cannot be processed.{NEWLINE}Please contact an administrator or a staff member if you think this is a mistake.{NEWLINE}See you soon!{NEWLINE}(this email was sent automatically)"),
+        'tlang'     => 'en_US',
+        'tcomment'  => _T('Lost password email (disabled)')
+    ),
 );
index ddaa31de3b030b87d74ddea705a185872a4e6319..7048972f54de2714412014e2ba5bfba422adb71a 100644 (file)
@@ -314,24 +314,38 @@ class AuthController extends AbstractController
         if ($adh->id != '') {
             //account has been found, proceed
             if (GaletteMail::isValidEmail($adh->email)) {
-                $password = new Password($this->zdb);
-                $res = $password->generateNewPassword($adh->id);
-                if ($res == true) {
+                $tparams = [
+                    'login_adh' => custom_html_entity_decode(
+                        $adh->login,
+                        ENT_QUOTES
+                    )
+                ];
+
+                //check if account is active
+                if (!$adh->isActive()) { //https://bugs.galette.eu/issues/1529
+                    $res = true;
+                    $text_id = 'pwddisabled';
+                } else {
+                    $password = new Password($this->zdb);
+                    $res = $password->generateNewPassword($adh->id);
+                    $text_id = 'pwd';
                     $link_validity = new \DateTime();
                     $link_validity->add(new \DateInterval('PT24H'));
+                    $tparams += [
+                        'change_pass_uri'   => $this->preferences->getURL() .
+                            $this->router->pathFor(
+                                'password-recovery',
+                                ['hash' => base64_encode($password->getHash())]
+                            ),
+                        'link_validity'     => $link_validity->format(_T("Y-m-d H:i:s")),
+                    ];
+                }
 
+                if ($res === true) {
                     $texts = new Texts(
                         $this->preferences,
                         $this->router,
-                        array(
-                            'change_pass_uri'   => $this->preferences->getURL() .
-                                                    $this->router->pathFor(
-                                                        'password-recovery',
-                                                        ['hash' => base64_encode($password->getHash())]
-                                                    ),
-                            'link_validity'     => $link_validity->format(_T("Y-m-d H:i:s")),
-                            'login_adh'         => custom_html_entity_decode($adh->login, ENT_QUOTES)
-                        )
+                        $tparams
                     );
                     $texts->getTexts($text_id, $adh->language);
 
index f660a64a18268719a9d7765baea94b45b51c85cd..be9d016de77023bcb1ae4ea796d78bf45018d80d 100644 (file)
@@ -88,17 +88,18 @@ class Texts extends atoum
      */
     public function testGetList()
     {
+        $count_texts = 13;
         $texts = new \Galette\Entity\Texts(
             $this->preferences
         );
         $texts->installInit();
 
         $list = $texts->getRefs(\Galette\Core\I18n::DEFAULT_LANG);
-        $this->array($list)->hasSize(12);
+        $this->array($list)->hasSize($count_texts);
 
         foreach (array_keys($this->i18n->getArrayList()) as $lang) {
             $list = $texts->getRefs($lang);
-            $this->array($list)->hasSize(12);
+            $this->array($list)->hasSize($count_texts);
         }
 
         if ($this->zdb->isPostgres()) {
@@ -107,7 +108,7 @@ class Texts extends atoum
             $results = $this->zdb->execute($select);
             $result = $results->current();
             $this->integer($result->last_value)
-                 ->isGreaterThanOrEqualTo(12, 'Incorrect texts sequence ' . $result->last_value);
+                 ->isGreaterThanOrEqualTo($count_texts, 'Incorrect texts sequence ' . $result->last_value);
 
             $this->zdb->db->query(
                 'SELECT setval(\'' . PREFIX_DB . $texts::TABLE . '_id_seq\', 1)',
@@ -119,7 +120,7 @@ class Texts extends atoum
         $texts->installInit(false);
 
         $list = $texts->getRefs(\Galette\Core\I18n::DEFAULT_LANG);
-        $this->array($list)->hasSize(12);
+        $this->array($list)->hasSize($count_texts);
 
         if ($this->zdb->isPostgres()) {
             $select = $this->zdb->select($texts::TABLE . '_id_seq');