Jump to content
camilolinares93

class AdminLoginControllerCore extends AdminController

Recommended Posts

Buenas noches requiero su colaboracion indicándome como debe colocar la siguientes lineas de texto que me arrojan un error 

 

public function processForgot()
    
        $email = trim(Tools::getValue('email_forgot'));
        if (empty($email))
            $this->errors[] = Tools::displayError('E-mail is empty');
        elseif (!Validate::isEmail($email))
            $this->errors[] = Tools::displayError('Invalid e-mail address');
        else
        {
            $employee = new Employee();
            if (!$employee->getByemail($email) || !$employee)
                $this->errors[] = Tools::displayError('This account does not exist');
            elseif ((strtotime($employee->last_passwd_gen.'+'.Configuration::get('PS_PASSWD_TIME_BACK').' minutes') - time()) > 0)
                $this->errors[] = sprintf(
                    Tools::displayError('You can regenerate your password only every %d minute(s)'),
                    Configuration::get('PS_PASSWD_TIME_BACK')
                );
        }
        if (_PS_MODE_DEMO_)
            $this->errors[] = Tools::displayError('This functionality has been disabled.');

        if (!count($this->errors))
        {    
            $pwd = Tools::passwdGen();
            $employee->passwd = md5(pSQL(_COOKIE_KEY_.$pwd));
            $employee->last_passwd_gen = date('Y-m-d H:i:s', time());

            $params = array(
                '{email}' => $employee->email,
                '{lastname}' => $employee->lastname,
                '{firstname}' => $employee->firstname,
                '{passwd}' => $pwd
            );
                        
            if (Mail::Send((int)Configuration::get('PS_LANG_DEFAULT'), 'password', Mail::l('Your new password', (int)Configuration::get('PS_LANG_DEFAULT')), $params, $employee->email, $employee->firstname.' '.$employee->lastname))
            {
                // Update employee only if the mail can be sent
                $result = $employee->update();
                if (!$result)
                    $this->errors[] = Tools::displayError('An error occurred during your password change.');
                else
                    die(Tools::jsonEncode(array(
                        'hasErrors' => false,
                        'confirm' => $this->l('Your password has been e-mailed to you', 'AdminTab', false, false)
                    )));
            }
            else
                die(Tools::jsonEncode(array(
                    'hasErrors' => true,
                    'errors' => array(Tools::displayError('An error occurred during your password change.'))
                )));
        
        }
        else if (Tools::isSubmit('ajax'))
            die(Tools::jsonEncode(array('hasErrors' => true, 'errors' => $this->errors)));
    }
    }
}
 

image.png

image.png

Share this post


Link to post
Share on other sites

Hola:

Te falta la llave de apertura después de la función:

public function processForgot() {

Te recomiendo tener cuidado al modificar el código fuente del Prestashop. Podrias "romper" otras cosas.

Saludos

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More