diff --git a/VERSIONS_HOTLINE/96483 b/VERSIONS_HOTLINE/96483 new file mode 100644 index 0000000000000000000000000000000000000000..348f008e466f259816517e79216918fdcd04a485 --- /dev/null +++ b/VERSIONS_HOTLINE/96483 @@ -0,0 +1 @@ + - ticket #96483 : Compte utilisateur : Les liens de réinitialisation de mot de passe envoyés par courriel expirent désormais en 24h \ No newline at end of file diff --git a/library/Class/Mail.php b/library/Class/Mail.php index fb3b43e08f606adae3fba5bf505623c51b59e9b3..3fdf7a80af82f1ebf206d2c0febb21fc5ac8e024 100644 --- a/library/Class/Mail.php +++ b/library/Class/Mail.php @@ -76,17 +76,7 @@ class Class_Mail { if (!$this->isMailValid($destinataire)) return $this->_("L'adresse e-mail du destinataire est incorrecte."); - - // Fusion - if($data) - { - foreach($data as $var => $valeur) - { - $var="{".$var."}"; - $body=str_replace($var,$valeur,$body); - } - } - $body = wordwrap($body, 60); + $body = $this->_injectDatasInto($data, $body); $statut = $this->mail($destinataire, $sujet, $body); @@ -96,6 +86,17 @@ class Class_Mail { } + protected function _injectDatasInto($data, $body) { + if (!$data) + return $body; + + foreach ($data as $name => $value) + $body = str_replace('{' . $name . '}', $value, $body); + + return $body; + } + + public function isMailValid($mail) { $validator = new Zend_Validate_EmailAddress(); return $validator->isValid($mail); @@ -105,4 +106,4 @@ class Class_Mail { public function getMailFrom() { return $this->mail_from; } -} \ No newline at end of file +} diff --git a/library/Class/User/LostPass.php b/library/Class/User/LostPass.php index 8ea5047aec07c92031f1fe14c787cdd549330194..1225309f77a03acc4354b479e61e174de4610399 100644 --- a/library/Class/User/LostPass.php +++ b/library/Class/User/LostPass.php @@ -24,7 +24,7 @@ class Class_User_LostPass { use Trait_TimeSource, Trait_Translator; - const MAX_MINUTES = 30; + const MAX_HOURS = 24; const TOKEN_SEPARATOR = '@'; const TOKEN_DATE_FORMAT = 'YmdHis'; @@ -56,7 +56,7 @@ class Class_User_LostPass { public function tokenHasExpiredFrom($date) { $from = DateTime::createFromFormat(static::TOKEN_DATE_FORMAT, $date); $now = new DateTime($this->getCurrentDateTime()); - $from->add(new DateInterval('PT' . static::MAX_MINUTES . 'M')); + $from->add(new DateInterval('PT' . static::MAX_HOURS . 'H')); return $from < $now; } @@ -141,9 +141,9 @@ class Class_User_LostPassResetLink extends Class_User_LostPassSender{ 'id' => $user->getId(), 'token' => $token, 'created' => $created_at_part], null, true)) - . $this->_("ATTENTION : ce lien créé à %s est valide pendant %s minutes\n", + . $this->_("ATTENTION : ce lien créé à %s est valide pendant %s heures\n", date('H:i', $created_at), - Class_User_LostPass::MAX_MINUTES) + Class_User_LostPass::MAX_HOURS) . sprintf("%s\n\n", $this->_('Bonne navigation sur le portail')); } diff --git a/tests/application/modules/opac/controllers/AuthControllerLostPasswordTest.php b/tests/application/modules/opac/controllers/AuthControllerLostPasswordTest.php index 481509f9164e32c1d101525e4a747694fbd4a4f8..e9fa77ea2aa2523979b63ff3de3ad4581285da89 100644 --- a/tests/application/modules/opac/controllers/AuthControllerLostPasswordTest.php +++ b/tests/application/modules/opac/controllers/AuthControllerLostPasswordTest.php @@ -96,7 +96,7 @@ class AuthControllerLostPasswordActionTest extends AuthControllerLostPasswordTes class AuthControllerLostPasswordValidPostTest extends AuthControllerLostPasswordTestCase { - protected $_mail_transport; + protected $_mail_transport, $_mail; public function setUp() { parent::setUp(); @@ -124,19 +124,27 @@ class AuthControllerLostPasswordValidPostTest extends AuthControllerLostPassword $user->beAbonneSIGB()->assertSave(); $this->postDispatch('/opac/auth/lostpass', ['lost_username' => 'Chambelle']); + $this->_mail = $this->_mail_transport->sent_mail; } /** @test */ public function mailShouldBeSent() { - $this->assertNotNull($this->_mail_transport->sent_mail); + $this->assertNotNull($this->_mail); } /** @test */ public function mailShouldContainsVousAvezFaitUneDemande() { $this->assertContains('Vous avez fait une demande', - $this->_mail_transport->sent_mail->getBodyText(true)); + $this->_mail->getBodyText(true)); + } + + + /** @test */ + public function mailShouldContainsExpirationIn24H() { + $this->assertContains('est valide pendant 24 heures', + $this->_mail->getBodyText(true)); } }