diff --git a/application/modules/telephone/controllers/AuthController.php b/application/modules/telephone/controllers/AuthController.php index 44132c8a9337361fd429a2c5ccf3009215ae5763..c665b804b868083ec6c352622e3364e67face6d3 100644 --- a/application/modules/telephone/controllers/AuthController.php +++ b/application/modules/telephone/controllers/AuthController.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with AFI-OPAC 2.0; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once ROOT_PATH.'application/modules/opac/controllers/AuthController.php'; @@ -35,24 +35,39 @@ class Telephone_AuthController extends AuthController { public function loginAction() { - $this->_loginCommon('/abonne'); + $this->view->preferences = Class_Profil::getCurrentProfil()->getCfgModulesPreferences('auth','login'); + $redirect = $this->_getParam('redirect', '/abonne'); + $this->view->redirect = $redirect; + $service = $this->_getParam('service',''); + $this->view->service = $service; + $this->view->titre = $this->view->_('Connexion'); + + $strategy = Auth_Strategy_Abstract::strategyForController($this); + $strategy->setDefaultUrl($redirect); + $strategy->processLogin(); + $this->_loginCommon(); $this->render('login-reservation'); } - public function loginReservationAction() { - $this->_loginCommon('/recherche/reservation'); - $this->view->id_notice = $this->_getParam('id'); + public function getRedirectDefaultUrl() { + return $this->_request->getParam('redirect','/abonne'); } - - protected function _loginCommon($redirectUrl) { + public function loginReservationAction() { if (Class_Users::getLoader()->hasIdentity()) { - $this->_redirect($redirectUrl); + $this->_redirect('/recherche/reservation'); return; } + $this->_loginCommon(); + $this->view->id_notice = $this->_getParam('id'); + } + + + + protected function _loginCommon() { $form = $this->_getFormLogin(); if ($this->_request->isPost()) { if (!($error = $this->_authenticate())) { @@ -63,14 +78,14 @@ class Telephone_AuthController extends AuthController { $this->_flashMessenger->addMessage($error); $this->_redirect($this->view->url(), array('prependBase' => false)); } - + $this->view->error = $this->_flashMessenger->getMessages(); $this->view->form = $form; } protected function _getFormLogin() { - + $settings = array_merge(['identifiant_exemple' => $this->view->_('N° de carte'), 'mot_de_passe_exemple' => $this->view->_('Mot de passe ou date de naissance')], Class_Profil::getPortail()->getModuleAccueilPreferencesByType('LOGIN')); diff --git a/library/ZendAfi/Form/NewsletterRegister.php b/library/ZendAfi/Form/NewsletterRegister.php index 354044de128b21c24dd3f23bc1adf26cbf7cef23..22f6ec021c0fdc0b96e7d1e4f00a2c28e4a10f6b 100644 --- a/library/ZendAfi/Form/NewsletterRegister.php +++ b/library/ZendAfi/Form/NewsletterRegister.php @@ -21,9 +21,6 @@ class ZendAfi_Form_NewsletterRegister extends ZendAfi_Form { - use Trait_Translator; - - public function init() { parent::init(); $this diff --git a/tests/application/modules/opac/controllers/AuthControllerTest.php b/tests/application/modules/opac/controllers/AuthControllerTest.php index 41fbd8ca896a3343dce25e242380559d4cb43360..392a4135e579a37508250f118382b4744a68e399 100644 --- a/tests/application/modules/opac/controllers/AuthControllerTest.php +++ b/tests/application/modules/opac/controllers/AuthControllerTest.php @@ -1656,7 +1656,7 @@ class AuthControllerPostRegisterNewsletterDailyNewsTest extends AuthControllerNo /** @test */ public function mailShouldContainsAccountMessage() { - $this->assertContains("Un compte vous a été créé automatiquement.\n\nCelui-ci vous permet de vous connecter en temps qu'invité et de vous désincrire de la newsletter.", $this->getSentMailContent()); + $this->assertContains("Un compte vous a été créé automatiquement.", $this->getSentMailContent()); } diff --git a/tests/application/modules/telephone/controllers/AuthControllerTest.php b/tests/application/modules/telephone/controllers/AuthControllerTest.php index e0a3d5ceba0a1ad5310bbbdc237b71ebb9e2adff..ffb0e68113d88e976d86dac90e1ffb98a64b9f30 100644 --- a/tests/application/modules/telephone/controllers/AuthControllerTest.php +++ b/tests/application/modules/telephone/controllers/AuthControllerTest.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with AFI-OPAC 2.0; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once 'TelephoneAbstractControllerTestCase.php'; @@ -64,12 +64,9 @@ class AuthControllerTelephoneBoiteLoginTest extends AuthControllerTelephoneWitho class AuthControllerTelephoneLoginTest extends AuthControllerTelephoneWithoutCommSIGBTestCase { public function setUp() { parent::setUp(); - Class_Profil::getCurrentProfil() - ->setCfgAccueil(array()); + Class_Profil::getCurrentProfil()->setCfgAccueil([]); - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Users') - ->whenCalled('hasIdentity') - ->answers(false); + ZendAfi_Auth::getInstance()->clearIdentity(); $this->dispatch('auth/login', true); } @@ -77,7 +74,7 @@ class AuthControllerTelephoneLoginTest extends AuthControllerTelephoneWithoutCom /** @test */ public function pageShouldContainsLoginInput() { - $this->assertXPath('//form//input[@name="username"]'); + $this->assertXPath('//form//input[@name="username"]', $this->_response->getBody()); } @@ -92,7 +89,7 @@ class AuthControllerTelephoneLoginTest extends AuthControllerTelephoneWithoutCom class AuthControllerTelephoneLoginReservationTest extends AuthControllerTelephoneWithoutCommSIGBTestCase { public function setUp() { parent::setUp(); - + $this->fixture('Class_Profil', [ 'id' => 1, 'cfg_accueil' => [ @@ -107,7 +104,7 @@ class AuthControllerTelephoneLoginReservationTest extends AuthControllerTelephon 'type_module' => 'LOGIN', 'preferences' => ['identifiant_exemple' => 'identity', 'mot_de_passe_exemple' => 'password']]]]]); - + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Users') ->whenCalled('hasIdentity') ->answers(false); @@ -133,7 +130,7 @@ class AuthControllerTelephoneLoginReservationTest extends AuthControllerTelephon $this->assertXPath('//form//input[@placeholder="identity"]',$this->_response->getBody()); } - + /** @test */ public function pageShouldContainsPlaceHollderPasswordIdentity() { $this->assertXPath('//form//input[@placeholder="password"]', $this->_response->getBody()); diff --git a/tests/application/modules/telephone/controllers/CasServerControllerTest.php b/tests/application/modules/telephone/controllers/CasServerControllerTest.php index 4a7506af44a704d44617a62d8539b22bc5184425..c88cc8f00c2cfaa2dfdff55877c48006fe720c9d 100644 --- a/tests/application/modules/telephone/controllers/CasServerControllerTest.php +++ b/tests/application/modules/telephone/controllers/CasServerControllerTest.php @@ -36,17 +36,27 @@ class Telephone_CasServerControllerTest extends TelephoneAbstractControllerTestC /** @test */ public function requestWithValidTicketResponseShouldContainsValidXML() { - $this->dispatch('/opac/cas-server/validate?ticket='.md5(Zend_Session::getId().'300').'&service=http://test.com', true); + $this->dispatch('/telephone/cas-server/validate?ticket='.md5(Zend_Session::getId().'300').'&service=http://test.com', true); $this->assertContains('<cas:user>300</cas:user>', $this->_response->getBody()); } /** @test */ public function requestOnV10WithValidTicketResponseShouldContainsGeorges87364() { - $this->dispatch('/opac/cas-server-v10/validate?ticket='.md5(Zend_Session::getId().'300').'&service=http://test.com', true); + $this->dispatch('/telephone/cas-server-v10/validate?ticket='.md5(Zend_Session::getId().'300').'&service=http://test.com', true); $this->assertContains('georges|87364', $this->_response->getBody()); } + + /** @test */ + public function loginOnCasOneZeroShouldRedirectToServiceWithTicket() { + $this->dispatch('/telephone/cas-server-v10/login?service=http://test.com', true); + $this->assertRedirectTo( + 'http://test.com?ticket='.(new Class_CasTicket())->getTicketForCurrentUser(), + $this->getResponseLocation()); + } + + } ?>