Jump to content

Soucis inscription clients mobile


Recommended Posts

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

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

Oulà... elle me fait mal aux yeux cette citation :-P

L'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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...