diff --git a/VERSIONS_HOTLINE/199363 b/VERSIONS_HOTLINE/199363 new file mode 100644 index 0000000000000000000000000000000000000000..c0e2d476728bfda954be9eff6d71020ec60d7a24 --- /dev/null +++ b/VERSIONS_HOTLINE/199363 @@ -0,0 +1 @@ + - correctif #199363 : Nanook : Changement de mot de passe, afficher un message d'erreur si la modification a échouée. \ No newline at end of file diff --git a/application/modules/opac/controllers/AuthController.php b/application/modules/opac/controllers/AuthController.php index e08a7f159b68134cd8458b6937ffd6a254746792..a08c9b944b872b44f56fb4a30004a83d4db9ad0d 100644 --- a/application/modules/opac/controllers/AuthController.php +++ b/application/modules/opac/controllers/AuthController.php @@ -451,7 +451,10 @@ class AuthController extends ZendAfi_Controller_Action { return $this->_redirect('/auth/login'); } - $this->_helper->notify($this->_('Votre mot de passe a été réinitialisé, vous pouvez vous connecter.')); + ($patron->hasErrors()) + ? $this->_helper->notify($this->_('La modification du mot de passe a échoué : %s', implode(BR,$patron->getErrors()) ), ['status' => 'error']) + : $this->_helper->notify($this->_('Votre mot de passe a été réinitialisé, vous pouvez vous connecter.')); + $this->_redirect('/auth/login'); } diff --git a/tests/application/modules/opac/controllers/AuthControllerResetPasswordTest.php b/tests/application/modules/opac/controllers/AuthControllerResetPasswordTest.php index ba98faa9d7f7cfdce9f7b94f6f17270a55eb84c1..69f54b5a80c268144e0b10df59f50928347f2979 100644 --- a/tests/application/modules/opac/controllers/AuthControllerResetPasswordTest.php +++ b/tests/application/modules/opac/controllers/AuthControllerResetPasswordTest.php @@ -260,3 +260,66 @@ class AuthControllerResetPasswordActionPostWithTwoUsersWithSameEmailTest 'La récupération de mot de passe n\'est pas possible pour cet email. Il est utilisé dans plusieurs comptes.'); } } + + + + +class AuthControllerResetPasswordErrorTest extends AuthControllerResetPasswordTestCase +{ + public function setUp() { + parent::setUp(); + + Class_HttpClientFactory::forTest(); + + $this->fixture(Class_IntBib::class, + ['id' => 1, + 'comm_sigb' => Class_IntBib::COM_NANOOK, + 'comm_params' => ['url_serveur' => 'https://localhost/afi_Nanook/ilsdi/']]); + + $user = $this->fixture(Class_Users::class, + ['id' => 12, + 'prenom' => 'Valentin', + 'nom' => 'Acloque', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, + 'id_site' => 1, + 'idabon' => '45789', + 'id_sigb' => '476', + 'login' => 'LEC000476', + 'password' => '2006', + 'id_int_bib' => 1]); + + $user->beAbonneSIGB()->assertSave(); + + Class_HttpClientFactory::getInstance() + ->getLastHttpClient() + + ->addRequestWithResponse('https://localhost:443/afi_Nanook/ilsdi/service/AuthenticatePatron/username/LEC000476/password/2006', + false) + + ->addRequestWithResponse('https://localhost:443/afi_Nanook/ilsdi/service/UpdatePatronInfo/patronId/476', + '<?xml version="1.0" encoding="UTF-8"?> +<UpdatePatronInfo><error>PatronUpdateError</error></UpdatePatronInfo>'); + + ZendAfi_Auth::getInstance()->clearIdentity(); + + $token = (new Class_User_LostPass($user))->tokenAt('20171130154500'); + $this->postDispatch($this->urlFor($user->getId(), $token, '20171130154500'), + ['new_pass' => 'secret', + 'confirm_pass' => 'secret']); + } + + + /** @test */ + public function allHttpCallsShouldHaveBeenCalled() { + Class_HttpClientFactory::getInstance() + ->getLastHttpClient() + ->checkCalls($this); + } + + + /** @test */ + public function flashMeesengerShouldContainsErrorMessage() + { + $this->assertFlashMessengerContentContains('La modification du mot de passe a échoué :'); + } +}