GazZzM@n Posted July 2, 2017 Share Posted July 2, 2017 Bonjour, J'utilise la version 1.5.4 de prestashop et rencontre un soucis avec l'inscription de certains clients utilisant un mobile ou une tablette. Ils rencontre une erreur pour adresse email invalide causée par un espace s'ajoutant au début ou à la fin de leur adresse mail. J'ai trouvé une solution sur le forum mais elle ne semble fonctionner que pour les versions 1.6 de prestashop, lorsque je modifie le fichier AuthController.php je me retrouve avec une erreur 500 sur la page d'authentification du site. Quelqu'un aurait une solution? Merci d'avance. Link to comment Share on other sites More sharing options...
GazZzM@n Posted July 2, 2017 Author Share Posted July 2, 2017 Bonjour, j'ai suivi cette procedure: Bonjour, Pour la validation du mail et son (ou ses espaces) en trop, vérifiez si dans votre fichier /controllers/front/AuthController.php vous avez bien ces lignes (avec le trim(Tools::getValue('email')) et $customer->getByEmail(trim($email), trim($passwd)); dans le bloc protected function processSubmitLogin() lignes 267 et suivantes /** * Process login */ protected function processSubmitLogin() { Hook::exec('actionBeforeAuthentication'); $passwd = trim(Tools::getValue('passwd')); $_POST['passwd'] = null; $email = trim(Tools::getValue('email')); if (empty($email)) { $this->errors[] = Tools::displayError('An email address required.'); } elseif (!Validate::isEmail($email)) { $this->errors[] = Tools::displayError('Invalid email address.'); } elseif (empty($passwd)) { $this->errors[] = Tools::displayError('Password is required.'); } elseif (!Validate::isPasswd($passwd)) { $this->errors[] = Tools::displayError('Invalid password.'); } else { $customer = new Customer(); $authentication = $customer->getByEmail(trim($email), trim($passwd)); if (isset($authentication->active) && !$authentication->active) {...Ensuite, remplacez le bloc, lignes 699 et suivantes:protected function processSubmitCreate() { if (!Validate::isEmail($email = Tools::getValue('email_create')) || empty($email)) { $this->errors[] = Tools::displayError('Invalid email address.'); } elseif (Customer::customerExists($email)) { $this->errors[] = Tools::displayError('An account using this email address has already been registered. Please enter a valid password or request a new one. ', false); $_POST['email'] = Tools::getValue('email_create'); unset($_POST['email_create']); } else { $this->create_account = true; $this->context->smarty->assign('email_create', Tools::safeOutput($email)); $_POST['email'] = $email; } } Par:protected function processSubmitCreate() { if (!Validate::isEmail($email = trim(Tools::getValue('email_create'))) || empty($email)) { $this->errors[] = Tools::displayError('Invalid email address.'); } elseif (Customer::customerExists(trim($email))) { $this->errors[] = Tools::displayError('An account using this email address has already been registered. Please enter a valid password or request a new one. ', false); $_POST['email'] = trim(Tools::getValue('email_create')); unset($_POST['email_create']); } else { $this->create_account = true; $this->context->smarty->assign('email_create', Tools::safeOutput($email)); $_POST['email'] = $email; } } La fonction trim() supprimant les espaces de début et de fin, vous ne devriez plus avoir ce souci. Link to comment Share on other sites More sharing options...
GazZzM@n Posted July 2, 2017 Author Share Posted July 2, 2017 j'utilise wordpad, les erreurs d'affichage semblent venir du quote, voici le lien vers le topic original: https://www.prestashop.com/forums/topic/471558-erreur-lors-de-linscription-client-adresse-mail-invalide/ Link to comment Share on other sites More sharing options...
GazZzM@n Posted July 2, 2017 Author Share Posted July 2, 2017 Je viens de faire la modification via Notepad++...Et tout fonctionne Je te remercie infiniment pour ton aide et te souhaite un bon dimanche. Link to comment Share on other sites More sharing options...
Eolia Posted July 2, 2017 Share Posted July 2, 2017 Oulà... elle me fait mal aux yeux cette citation :-PL'original était: Bonjour, Pour la validation du mail et son (ou ses espaces) en trop, vérifiez si dans votre fichier /controllers/front/AuthController.php vous avez bien ces lignes (avec le trim(Tools::getValue('email')) et $customer->getByEmail(trim($email), trim($passwd)); dans le bloc protected function processSubmitLogin() lignes 267 et suivantes /** * Process login */ protected function processSubmitLogin() { Hook::exec('actionBeforeAuthentication'); $passwd = trim(Tools::getValue('passwd')); $_POST['passwd'] = null; $email = trim(Tools::getValue('email')); if (empty($email)) { $this->errors[] = Tools::displayError('An email address required.'); } elseif (!Validate::isEmail($email)) { $this->errors[] = Tools::displayError('Invalid email address.'); } elseif (empty($passwd)) { $this->errors[] = Tools::displayError('Password is required.'); } elseif (!Validate::isPasswd($passwd)) { $this->errors[] = Tools::displayError('Invalid password.'); } else { $customer = new Customer(); $authentication = $customer->getByEmail(trim($email), trim($passwd)); if (isset($authentication->active) && !$authentication->active) { ... Ensuite, remplacez le bloc, lignes 699 et suivantes: protected function processSubmitCreate() { if (!Validate::isEmail($email = Tools::getValue('email_create')) || empty($email)) { $this->errors[] = Tools::displayError('Invalid email address.'); } elseif (Customer::customerExists($email)) { $this->errors[] = Tools::displayError('An account using this email address has already been registered. Please enter a valid password or request a new one. ', false); $_POST['email'] = Tools::getValue('email_create'); unset($_POST['email_create']); } else { $this->create_account = true; $this->context->smarty->assign('email_create', Tools::safeOutput($email)); $_POST['email'] = $email; } } Par: protected function processSubmitCreate() { if (!Validate::isEmail($email = trim(Tools::getValue('email_create'))) || empty($email)) { $this->errors[] = Tools::displayError('Invalid email address.'); } elseif (Customer::customerExists(trim($email))) { $this->errors[] = Tools::displayError('An account using this email address has already been registered. Please enter a valid password or request a new one. ', false); $_POST['email'] = trim(Tools::getValue('email_create')); unset($_POST['email_create']); } else { $this->create_account = true; $this->context->smarty->assign('email_create', Tools::safeOutput($email)); $_POST['email'] = $email; } } La fonction trim() supprimant les espaces de début et de fin, vous ne devriez plus avoir ce souci. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now