Commit f4cca1a2 authored by Laurent's avatar Laurent Committed by Patrick Barroca
Browse files

hotline #98553 chrome workaround for autocomplete="off" not working. See...

hotline #98553 chrome workaround for autocomplete="off" not working. See https://stackoverflow.com/questions/15738259/disabling-chrome-autofill
parent 00b664c3
Pipeline #8758 passed with stage
in 46 minutes and 19 seconds
- ticket #98553 : Correction de la prise en compte des Captchas sous Chrome (78)
\ No newline at end of file
......@@ -378,7 +378,7 @@ class AuthController extends ZendAfi_Controller_Action {
return;
}
if ('' != $this->_getParam('emailCheck'))
if ('' != $this->_getParam('website'))
return $this->_redirect('/');
$this->view->preferences = Class_Profil::getCurrentProfil()->getCfgModulesPreferences('auth', 'register');
......@@ -420,7 +420,7 @@ class AuthController extends ZendAfi_Controller_Action {
public function newsletterRegisterAction() {
if('' != $this->_request->getParam('emailCheck'))
if('' != $this->_request->getParam('website'))
return $this->_redirect('/');
if(!($id_newsletter = $this->_request->getParam('id')))
......@@ -554,34 +554,33 @@ class AuthController extends ZendAfi_Controller_Action {
return $this->_redirect('opac/index');
}
if ('' != $this->_getParam('emailCheck'))
if ('' != $this->_getParam('website'))
return $this->_redirect('/');
$this->view->form =
$form->populate(ZendAfi_Filters_Post::filterStatic($this->_request->getParams()));
$data = ZendAfi_Filters_Post::filterStatic($this->_request->getPost());
unset($data['emailCheck']);
unset($data['website']);
if ($this->_request->isPost() && $form->isValid($data)) {
$pre_registration->send($data);
$pre_registration->getErrors()->isEmpty()
? $this->_preRegistrationSuccess()
: $this->_preRegistrationFailed(implode(BR, $pre_registration->getErrors()->getArrayCopy()));
? $this->_preRegistrationSuccess($pre_registration)
: $this->_preRegistrationFailed($pre_registration);
}
}
protected function _preRegistrationFailed($message) {
$this->_helper->notify($message);
$this->_preRegistrationRedirect('pre-registration');
protected function _preRegistrationFailed($pre_registration) {
$this->_helper->notify(implode(BR, $pre_registration->getErrors()->getArrayCopy()));
$this->_preRegistrationRedirect('pre-registration', $pre_registration);
}
protected function _preRegistrationSuccess() {
protected function _preRegistrationSuccess($pre_registration) {
$this->_preRegistrationSuccessFull();
$this->view->library = $this->view->annexe->getBib();
$email = $this->_getParam('email', $this->_getParam('mail', ''));
$mail_admin = Class_Profil::getCurrentProfil()->getMailSiteOrPortail();
......@@ -601,31 +600,30 @@ class AuthController extends ZendAfi_Controller_Action {
$this->_helper->notify($this->_('Un email de confirmation de préinscription vous a été envoyé à l\'adresse %s .', $this->view->tag('b', $email)));
return $this->_preRegistrationRedirect('pre-registration-success');
return $this->_preRegistrationRedirect('pre-registration-success', $pre_registration);
}
protected function _preRegistrationRedirect($action) {
$this->_redirect($this->view->absoluteUrl(array_filter(array_merge(['action' => $action,
'emailCheck' => null],
$this->_request->getPost()))));
protected function _preRegistrationRedirect($action, $pre_registration) {
$library = $pre_registration->getBib($this->_request->getPost());
$this->_redirect($this->view->absoluteUrl(['action' => $action,
'id_bib' => $library->getId()]));
}
public function preRegistrationSuccessAction() {
$this->view->titre = $this->_('Préinscription');
$this->_preRegistrationSuccessFull();
$this->view->library = Class_Bib::find($this->_getParam('id_bib'));
$pre_registration = new Class_WebService_SIGB_PreRegistration();
$this->view->form = $pre_registration->getForm()
->populate($this->_request->getParams());
}
protected function _preRegistrationSuccessFull() {
$pre_registration = new Class_WebService_SIGB_PreRegistration();
$this->view->branchcode = $pre_registration->getBranchCode($this->_request->getParams());
$this->view->annexe = Class_CodifAnnexe::findFirstBy(['code' => $this->view->branchcode]);
$this->view->library = $this->view->annexe->getBib();
$params = $this->_request->getParams();
$this->view->library = (new Class_WebService_SIGB_PreRegistration())->getBib($params);
$this->view->library_label = $this->view->library->getLibelle();
$this->view->form = $pre_registration->getForm()
->populate($this->_request->getParams());
}
......
......@@ -23,10 +23,10 @@ class FormulaireController extends ZendAfi_Controller_Action {
$article = Class_Article::find($this->_getParam('id_article'));
$post = $this->_request->getPost();
if ($this->_getParam('emailCheck'))
if ($this->_getParam('website'))
return $this->_redirect('/');
unset($post['emailCheck']);
unset($post['website']);
$formulaire = new Class_Formulaire();
$formulaire->setData(serialize($post))
......
......@@ -71,7 +71,7 @@ class IndexController extends ZendAfi_Controller_Action {
public function formulairecontactAction() {
if('' != $this->_getParam('emailCheck'))
if('' != $this->_getParam('website'))
$this->_redirect('/');
$this->view->form = new ZendAfi_Form_ContactForm();
......
......@@ -1021,10 +1021,10 @@ class Class_Article extends Storm_Model_Abstract {
$end_form = '</form>';
$antispam_tag = '<input data-spambots="true" autocomplete="off" name="emailCheck" type="text" />';
$antispam_tag = '<input data-spambots="true" autocomplete="off" name="websiteCheck" type="text" />';
$replaced_form = str_replace($antispam_tag, '', $replaced_form);
if (false === strpos($replaced_form, 'name="emailCheck"'))
if (false === strpos($replaced_form, 'name="websiteCheck"'))
$replaced_form = preg_replace('|' . $end_form .'|i',
$antispam_tag . $end_form,
$replaced_form);
......
......@@ -45,6 +45,13 @@ class Class_WebService_SIGB_PreRegistration {
}
public function getBib($data) {
$code = $this->getBranchCode($data);
$annex = Class_CodifAnnexe::findFirstBy(['code' => $code]);
return $annex->getBib();
}
protected function getStrategy() {
if ($this->_strategy)
return $this->_strategy;
......@@ -108,8 +115,8 @@ class Class_WebService_SIGB_PreRegistrationAbstract {
class Class_WebService_SIGB_PreRegistrationNanook extends Class_WebService_SIGB_PreRegistrationAbstract{
class Class_WebService_SIGB_PreRegistrationNanook extends Class_WebService_SIGB_PreRegistrationAbstract{
public function getForm() {
return new ZendAfi_Form_PreRegistration_Nanook();
}
......@@ -127,7 +134,9 @@ class Class_WebService_SIGB_PreRegistrationNanook extends Class_WebService_SIGB_
public function getBranchCode($data) {
return $data['site'];
return isset($data['site'])
? $data['site']
: 0;
}
}
......
......@@ -101,7 +101,8 @@ class ZendAfi_Form_ContactForm extends ZendAfi_Form {
'validators' => ['NoHtml']
])
->addElement('text', 'emailCheck', ['data-spambots' => 'true'])
->addElement('text', 'website', ['data-spambots' => 'true',
'autocomplete' => 'off'])
->addElement('timer', 'timer', ['session' => Zend_Registry::get('session'),
'salt' => __CLASS__,
......
......@@ -30,9 +30,9 @@ class ZendAfi_Form_NewsletterRegister extends ZendAfi_Form {
'size' => 75,
'required' => true,
'allowEmpty'=> false])
->addElement('text', 'emailCheck', [
'data-spambots' => 'negative-captcha',
'autocomplete' => 'off'])
->addElement('text', 'website', [
'data-spambots' => 'negative-captcha',
'autocomplete' => 'off'])
->addElement('submit', 'submit', ['label' => $this->_('Valider')]);
}
}
......
......@@ -77,7 +77,7 @@ class ZendAfi_Form_PreRegistration_Koha extends ZendAfi_Form {
'required' => true])
->addElement('text',
'emailCheck',
'website',
['data-spambots' => 'true',
'autocomplete' => 'off'])
......@@ -98,7 +98,7 @@ class ZendAfi_Form_PreRegistration_Koha extends ZendAfi_Form {
'address_fieldset',
['legend' => $this->_('Votre adresse')])
->addDisplayGroup(['email', 'phone', 'emailCheck'],
->addDisplayGroup(['email', 'phone', 'website'],
'contact_fieldset',
['legend' => $this->_('Information de contact')]);
......
......@@ -56,7 +56,7 @@ class ZendAfi_Form_PreRegistration_Nanook extends ZendAfi_Form {
'validators' => [new ZendAfi_Validate_MailEquals('mail')]])
->addElement('text',
'emailCheck',
'website',
['data-spambots' => 'true',
'autocomplete' => 'off'
])
......
......@@ -62,10 +62,10 @@ class ZendAfi_Form_Register extends ZendAfi_Form {
'allowEmpty' => false,
'validators' => [new ZendAfi_Validate_MailEquals('mail')]])
->addElement('text', 'emailCheck', ['data-spambots' => 'true',
'autocomplete' => 'off'])
->addElement('text', 'website', ['data-spambots' => 'true',
'autocomplete' => 'off'])
->addDisplayGroup(['login', 'mdp', 'mdp2', 'mail', 'mail2', 'emailCheck'],
->addDisplayGroup(['login', 'mdp', 'mdp2', 'mail', 'mail2', 'website'],
'fields',
['legend' => '']);
......
......@@ -22,6 +22,9 @@
class ZendAfi_View_Helper_TagPreRegistration extends ZendAfi_View_Helper_BaseHelper {
public function tagPreRegistration($library, $form, $html = true) {
if (!$library)
return $this->_tag('p', $this->_('Votre demande d\'inscription a bien été enregistrée.'));
$library_label = $library->getLibelle();
$success = $this->_('Votre demande d\'inscription à %s a bien été enregistrée.', ($html ? $this->_tag('b', $library_label) : $library_label));
......@@ -32,11 +35,7 @@ class ZendAfi_View_Helper_TagPreRegistration extends ZendAfi_View_Helper_BaseHel
: $this->view->tagLibraryAddress($library)));
return $html
? ($this->_tag('p', $success) .
$this->_tag('p', $address) .
$this->_tag('div',
$this->_tag('p', $this->_('Récapitulatif des informations')) .
$this->view->renderForm($form->lock()),
['class' => 'pre-registration-form-wrapper']))
$this->_tag('p', $address))
: $success . "\n" . $address;
}
}
\ No newline at end of file
......@@ -75,7 +75,6 @@
(gtags-mode t)
(setq ag-highlight-search t)
(setq ag-arguments (list "--smart-case"
"--nogroup"
"--column"
"--ignore" "phonetix.txt"
"--ignore" "TAGS"
......
......@@ -118,8 +118,8 @@ class AuthControllerPreRegistrationKohaDispatchTest extends AuthControllerPreReg
/** @test */
public function inputEmailCheckForSpamBotsShouldBePresent() {
$this->assertXPath('//input[@name="emailCheck"][@data-spambots="true"][@autocomplete="off"]');
public function inputAntiSpamWebsiteForSpamBotsShouldBePresent() {
$this->assertXPath('//input[@name="website"][@data-spambots="true"][@autocomplete="off"]');
}
}
......@@ -155,13 +155,13 @@ class AuthControllerPreRegistrationKohaPostDispatchTest extends AuthControllerPr
'city' => 'Gotham',
'email' => 'thom@mail.com',
'phone' => '0123456789',
'emailCheck' => '']);
'website' => '']);
}
/** @test */
public function responseShouldRedirectToPreRegistration() {
$this->assertRedirectTo('http://localhost' . BASE_URL . '/auth/pre-registration-success/branchcode/1%7CGRA/surname/Boulard/firstname/Thom/dateofbirth/15-09-1940/streetnumber/10/address/rue+secret/zipcode/01630/city/Gotham/email/thom%40mail.com/phone/0123456789');
public function responseShouldRedirectToPreRegistrationIdBibFive() {
$this->assertRedirectTo('http://localhost' . BASE_URL . '/auth/pre-registration-success/id_bib/5');
}
......@@ -187,7 +187,7 @@ class AuthControllerKohaPreRegistrationSpammedPostDispatchTest extends AuthContr
'address' => 'rue secret',
'zipcode' => '01630',
'email' => 'thom@mail.com',
'emailCheck' => 'imabot@wcry.ru'],
'website' => 'imabot@wcry.ru'],
true);
}
......@@ -236,8 +236,8 @@ class AuthControllerPreRegistrationKohaPostDispatchWithErrorReturnedTest extends
/** @test */
public function responseShouldRedirectToPreRegistrationError() {
$this->assertRedirectTo('http://localhost' . BASE_URL . '/auth/pre-registration/branchcode/1%7CGRA/surname/Boulard/firstname/Thom/dateofbirth/15%2F09%2F1940/streetnumber/10/address/rue+secret/zipcode/01630/city/Gotham/email/thom%40mail.com/phone/0123456789');
public function responseShouldRedirectToPreRegistrationErrorIdBibFive() {
$this->assertRedirectTo('http://localhost' . BASE_URL . '/auth/pre-registration/id_bib/5');
}
}
......@@ -248,7 +248,7 @@ class AuthControllerPreRegistrationKohaSuccessDispatchTest extends AuthControlle
public function setUp() {
parent::setUp();
$this->dispatch('/auth/pre-registration-success/branchcode/1%7CGRA/surname/Boulard/firstname/Thom/dateofbirth/15-09-1940/address/rue+secret/zipcode/01630/email/thom%40mail.com', true);
$this->dispatch('/auth/pre-registration-success/id_bib/5', true);
}
......@@ -262,12 +262,6 @@ class AuthControllerPreRegistrationKohaSuccessDispatchTest extends AuthControlle
public function successMessageShouldContainsGransAddress() {
$this->assertXPathContentContains('//div//p', 'Afin de finaliser votre inscription, merci de vous rendre dans votre médiathèque : <b>1 rue proche de la mer 83756 Juan les Pins</b>');
}
/** @test */
public function dateofBirthShouldBeDisbled() {
$this->assertXPath('//form//input[@name="dateofbirth"][@type="text"][@disabled="disabled"][@value="15/09/1940"]');
}
}
......@@ -334,7 +328,7 @@ class AuthControllerPreRegistrationNanookDispatchTest
/** @test */
public function formShouldContainsCaptcha() {
$this->assertXPath('//input[@name="emailCheck"][@data-spambots="true"][@autocomplete="off"]');
$this->assertXPath('//input[@name="website"][@data-spambots="true"][@autocomplete="off"]');
}
}
......@@ -371,19 +365,13 @@ class AuthControllerPreRegistrationNanookPostDispatchTest
'town' => 'titi',
'zipcode' => '123456',
'address' => '123',
'emailCheck' => '']);
'website' => '']);
}
/** @test */
public function shouldRedirect() {
$this->assertRedirect();
}
/** @test */
public function responseShouldRedirectToPreRegistrationSuccess() {
$this->assertRedirectTo('http://localhost' . BASE_URL . '/auth/pre-registration-success/site/1/lastName/Jiro/firstName/Tom/mail/test%40test.fr/mail2/test%40test.fr/password/pwd123456/password2/pwd123456/birthDate/2001-05-05/town/titi/zipcode/123456/address/123');
public function responseShouldRedirectToPreRegistrationSuccessIdBibOne() {
$this->assertRedirectTo('http://localhost' . BASE_URL . '/auth/pre-registration-success/id_bib/1');
}
......@@ -439,13 +427,13 @@ class AuthControllerPreRegistrationNanookPostDispatchErrorTest
'town' => 'titi',
'zipcode' => '123456',
'address' => '123',
'emailCheck' => '']);
'website' => '']);
}
/** @test */
public function responseShouldRedirectToPreRegistrationError() {
$this->assertRedirectTo('http://localhost' . BASE_URL . '/auth/pre-registration/site/1/lastName/Jiro/firstName/Tom/mail/test%40test.fr/mail2/test%40test.fr/password/pwd123456/password2/pwd123456/birthDate/2001-05-05/town/titi/zipcode/123456/address/123');
public function responseShouldRedirectToPreRegistrationErrorIdBibOne() {
$this->assertRedirectTo('http://localhost' . BASE_URL . '/auth/pre-registration/id_bib/1');
}
}
......@@ -468,7 +456,7 @@ class AuthControllerPreRegistrationNanookPostDispatchSpamTest
'town' => 'titi',
'zipcode' => '123456',
'address' => '123',
'emailCheck' => 'russian-pal@poutine.ru']);
'website' => 'russian-pal@poutine.ru']);
}
......@@ -480,6 +468,23 @@ class AuthControllerPreRegistrationNanookPostDispatchSpamTest
class AuthControllerPreRegistrationNanookSuccessDispatchTest extends AuthControllerPreRegistrationNanookTestCase {
/** @test */
public function withSiteGivenShouldDisplayLibraryName() {
$this->dispatch('/auth/pre-registration-success/id_bib/1', true);
$this->assertXPathContentContains('//div//p', 'Votre demande d\'inscription à <b>Arcadia</b> a bien été enregistrée.', $this->_response->getBody());
}
/** @test */
public function withoutSiteShouldNotDisplayLibraryName() {
$this->dispatch('/auth/pre-registration-success', true);
$this->assertXPathContentContains('//div//p', 'Votre demande d\'inscription a bien été enregistrée.', $this->_response->getBody());
}
}
class AuthControllerPreRegistrationWithNoPreRegistrationTest extends AuthControllerPreRegistrationNanookTestCase {
public function setUp() {
......
......@@ -1435,8 +1435,8 @@ class AuthControllerNobodyLoggedAndRegistrationAllowedRegisterTest extends AuthC
/** @test */
public function inputEmailCheckForSpamBotsShouldBePresent() {
$this->assertXPath('//input[@name="emailCheck"][@data-spambots="true"][@autocomplete="off"]');
public function inputWebsiteForSpamBotsShouldBePresent() {
$this->assertXPath('//input[@name="website"][@data-spambots="true"][@autocomplete="off"]');
}
......@@ -1570,7 +1570,7 @@ class AuthControllerNobodyLoggedRegisterPostRightDatasTest
'mdp2' => 'secret',
'lastname' => 'bros',
'firstname' => 'mario',
'emailCheck' => '']);
'website' => '']);
$this->_from = $this->getSentMail()->getFrom();
$this->_recipients = $this->getSentMail()->getRecipients();
......@@ -1690,7 +1690,7 @@ class AuthControllerNobodyLoggedRegisterSendBibNotification extends AuthControll
'id_site' => 10,
'lastname' => 'bros',
'firstname' => 'mario',
'emailCheck' => ''];
'website' => ''];
$this->postDispatch('auth/register',
$user);
......@@ -1840,7 +1840,7 @@ class AuthControllerNobodyLoggedRegisterPostWrongDataTest extends AuthController
/** @test */
public function withEmailCheckNotEmptyShouldRedirectToRoot() {
public function withWebSiteForSpamBotsNotEmptyShouldRedirectToRoot() {
$this->postDispatch('auth/register',
['login' => 'mario',
'mail' => 'mario@afi-sa.fr',
......@@ -1849,7 +1849,7 @@ class AuthControllerNobodyLoggedRegisterPostWrongDataTest extends AuthController
'mdp2' => 'secret',
'lastname' => 'bros',
'firstname' => 'mario',
'emailCheck' => 'something@somewhere.com']);
'website' => 'something.somewhere.com']);
$this->assertRedirectTo('/');
......@@ -2055,7 +2055,7 @@ class AuthControllerNewsletterRegisterKickSpamBotsTest extends AuthControllerNob
$this->postDispatch('/opac/auth/newsletter-register/id/5', [
'email' => 'imnotabot@factory.bot',
'emailCheck' => 'imnotabot@factory.bot']);
'website' => 'imnotabot.factory.bot']);
}
......@@ -2100,7 +2100,7 @@ class AuthControllerNobodyLoggedAndRegisterNewsletterTest extends AuthController
/** @test */
public function negativeCaptchaShouldBePresent() {
$this->assertXPath('//form//input[@name="emailCheck"][@data-spambots="negative-captcha"][@autocomplete="off"]');
$this->assertXPath('//form//input[@name="website"][@data-spambots="negative-captcha"][@autocomplete="off"]');
}
......@@ -2127,7 +2127,7 @@ class AuthControllerPostRegisterNewsletterDailyNewsTest extends AuthControllerNo
$this->fixture('Class_Newsletter', ['id' => 5, 'titre' => 'Daily News']);
$this->postDispatch('/opac/auth/newsletter-register/id/5', ['email' => 'iwanttobespamed@abo.bzh',
'emailCheck' => '']);
'website' => '']);
}
......@@ -2231,7 +2231,7 @@ class AuthControllerPostRegisterNewsletterDailyNewsWithNonUniqueMailTest extends
$this->postDispatch('/opac/auth/newsletter-register/id/5', [
'email' => 'imalreadyused@mail.com',
'emailCheck' => '']);
'website' => '']);
}
......@@ -2259,7 +2259,7 @@ class AuthControllerPostRegisterNewsletterDailyNewsWithBadMailTest extends AuthC
$this->fixture('Class_Newsletter', ['id' => 5, 'titre' => 'Daily News']);
$this->postDispatch('/opac/auth/newsletter-register/id/5', ['email' => 'bad_mail!',
'emailCheck' => '']);
'website' => '']);
}
/** @test */
......@@ -2521,7 +2521,7 @@ class AuthControllerNewsletterRegisterSendMailWrongMailConfigurationTest extends
$this->fixture('Class_Newsletter', ['id' => 5, 'titre' => 'Daily News']);
$this->postDispatch('/opac/auth/newsletter-register/id/5', ['email' => 'iwanttobespamed@abo.it',
'emailCheck' => '']);
'website' => '']);
}
......
......@@ -113,16 +113,16 @@ class FormulaireContactInvalidEmailHoneyPotPostTest extends AbstractControllerTe
/** @test */
public function formShouldContainsInputEmailCheck() {
public function formShouldContainsInputAntiSpamWebsite() {
$this->dispatch('/index/formulairecontact', true);
$this->assertXPath('//input[@name="emailCheck"]');
$this->assertXPath('//input[@name="website"]');
}
/** @test */
public function botShouldBeRedirect() {
$this->postDispatch('/opac/index/formulairecontact',
['emailCheck' => 'email@email.com']);
['website' => 'email@email.com']);
$this->assertRedirectTo('/');
}
}
......
......@@ -122,7 +122,7 @@ class FormulaireControllerPostActionTest extends FormulaireControllerPostActionT
$this->postDispatch('/formulaire/add/id_article/45',
['nom' => 'Tinguette' ,
'prenom' => 'Quentin',
'emailCheck' => ''],
'website' => ''],
true);
$this->new_formulaire = Class_Formulaire::find(2);
......@@ -213,7 +213,7 @@ class FormulaireControllerPostAsBotTest extends FormulaireControllerPostActionTe
$this->postDispatch('/formulaire/add/id_article/45',
['nom' => 'Tinguette' ,
'prenom' => 'Quentin',
'emailCheck' => 'i am a bot'],
'website' => 'i am a bot'],
true);
$this->new_formulaire = Class_Formulaire::find(2);
......
......@@ -40,7 +40,7 @@ class ArticleFormulaireInternalTest extends ViewHelperTestCase {
POST<form method="POST" id="without_action">
<input type="button" value="likebutton" />
<input data-spambots="true" autocomplete="off" name="emailCheck" type="text" />
<input data-spambots="true" autocomplete="off" name="websiteCheck" type="text" />
</form>
EMPTY<form id="empty">
</form>
......@@ -59,10 +59,10 @@ class ArticleFormulaireInternalTest extends ViewHelperTestCase {
/** @test */
public function eachFormShouldContainsInputEmailCheckForSpamBot() {
public function eachFormShouldContainsInputWebsiteCheckForSpamBot() {
$this
->assertXPathCount($this->_content,
'//form/input[@name="emailCheck"][@data-spambots="true"][@autocomplete="off"]',
'//form/input[@name="websiteCheck"][@data-spambots="true"][@autocomplete="off"]',
3);
}
...