Zulan Posted January 8, 2013 Share Posted January 8, 2013 Hello, I was trying to upgrade my 1.4.9 to 1.5 and it failed. I tried all kinds of stuff but I never got it to work. I then created a new site and migrated all the data using a payed service. All is well except for the customers passwords. The recomendation is for the customer to have to create a new password using the link. This is not something I want my customers to go through and if it was me I might have cancelled my order if I couldnt log in. So I'm trying to move the salt and hashes and all that stuff from my old installation. Just moving COOKIE_KEY and COOKIE_IV doesnt help and then I cant login to the admin site either. The 1.5.3.1 database as a salt table that is empty, maybe I can copy the salt info from the 1.4.9 installation somewhere? I tried the COOKIE_KEY and COOKIE_IV but that didnt work. I also tried the secure key table in 1.4.9 database but I wasnt even able to paste it in there, I guess it was too long. Any ideas? Link to comment Share on other sites More sharing options...
gonebdg - webindoshop.com Posted January 9, 2013 Share Posted January 9, 2013 Edit file ../config/settings.inc.php , and add : define('_COOKIE_KEY_OLD_', 'YOUR_PS_V.1.4.9_COOKIE_KEY_'); Edit file ../override/classes/Customer.php, and add : public function getByEmail_old($email, $passwd = null, $ignore_guest = true) { if (!Validate::isEmail($email) || ($passwd && !Validate::isPasswd($passwd))) die (Tools::displayError()); $sql = 'SELECT * FROM `'._DB_PREFIX_.'customer` WHERE `email` = \''.pSQL($email).'\' '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).' '.(isset($passwd) ? 'AND `passwd` = \''.Tools::encrypt_old($passwd).'\'' : '').' AND `deleted` = 0'. ($ignore_guest ? ' AND `is_guest` = 0' : ''); $result = Db::getInstance()->getRow($sql); if (!$result) return false; $this->id = $result['id_customer']; foreach ($result as $key => $value) if (key_exists($key, $this)) $this->{$key} = $value; return $this; } Edit file ../override/classes/Tools.php, and add : public static function encrypt_old($passwd) { return md5(_COOKIE_KEY_OLD_.$passwd); } Edit file ../override/controllers/front/AuthController.php, and add : protected function processSubmitLogin() { Hook::exec('actionBeforeAuthentication'); $passwd = trim(Tools::getValue('passwd')); $email = trim(Tools::getValue('email')); if (empty($email)) $this->errors[] = Tools::displayError('E-mail address required'); elseif (!Validate::isEmail($email)) $this->errors[] = Tools::displayError('Invalid e-mail 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)); $authentication_old = $customer->getByEmail_old(trim($email), trim($passwd)); if ((!$authentication AND !$authentication_old) || !$customer->id) $this->errors[] = Tools::displayError('Authentication failed'); else { $this->context->cookie->id_compare = isset($this->context->cookie->id_compare) ? $this->context->cookie->id_compare: CompareProduct::getIdCompareByIdCustomer($customer->id); $this->context->cookie->id_customer = (int)($customer->id); $this->context->cookie->customer_lastname = $customer->lastname; $this->context->cookie->customer_firstname = $customer->firstname; $this->context->cookie->logged = 1; $customer->logged = 1; $this->context->cookie->is_guest = $customer->isGuest(); $this->context->cookie->passwd = $customer->passwd; $this->context->cookie->email = $customer->email; // Add customer to the context $this->context->customer = $customer; if (Configuration::get('PS_CART_FOLLOWING') && (empty($this->context->cookie->id_cart) || Cart::getNbProducts($this->context->cookie->id_cart) == 0)) $this->context->cookie->id_cart = (int)Cart::lastNoneOrderedCart($this->context->customer->id); // Update cart address $this->context->cart->id = $this->context->cookie->id_cart; $this->context->cart->setDeliveryOption(null); $this->context->cart->id_address_delivery = Address::getFirstCustomerAddressId((int)($customer->id)); $this->context->cart->id_address_invoice = Address::getFirstCustomerAddressId((int)($customer->id)); $this->context->cart->secure_key = $customer->secure_key; $this->context->cart->update(); $this->context->cart->autosetProductAddress(); Hook::exec('actionAuthentication'); // Login information have changed, so we check if the cart rules still apply CartRule::autoRemoveFromCart($this->context); CartRule::autoAddToCart($this->context); if (!$this->ajax) { if ($back = Tools::getValue('back')) Tools::redirect(html_entity_decode($back)); Tools::redirect('index.php?controller=my-account'); } } } if ($this->ajax) { $return = array( 'hasError' => !empty($this->errors), 'errors' => $this->errors, 'token' => Tools::getToken(false) ); die(Tools::jsonEncode($return)); } else $this->context->smarty->assign('authentification_error', $this->errors); } Finally create csv file to update XX_customer_group table database for all id_customer set group to 3 (customer), and import to your Prestashop database Done AuthController.php Customer.php Tools.php 2 Link to comment Share on other sites More sharing options...
larsijj Posted March 5, 2013 Share Posted March 5, 2013 Hello Gonebdg, I followed everything you said above here but it seems to not work?(still getting authentication failed) Do i need to re-import all my customers after this fix? since i have done the import before the fix? All tough i did fully restore the customer group through the database. About the customers it self i have done this through CSV imporrt within the back office of prestashop is this the right way or should i do this through the database? Kind regards, Lars van Oostrum Link to comment Share on other sites More sharing options...
gonebdg - webindoshop.com Posted March 5, 2013 Share Posted March 5, 2013 Hi Lars, Did you have modify your prestashop settings.inc.php file as mentioned above ? I've uploaded 3 files above, so you don't have to edit the overriden files. Did you use it and have uploading it into the right directory ? Did you do the last thing that has been mentioned above ? Finallycreate csv file to update XX_customer_group table database for all id_customer set group to 3 (customer), and import to your Prestashop database Link to comment Share on other sites More sharing options...
derenyi Posted July 28, 2013 Share Posted July 28, 2013 Hello Gonebdg, I also failed with it (fresh install of 1.5.4), so let me ask very specific questions: - I added the line to the settings.inc.php file - In my override/classes diretory there was not those files, that you mentioned (Customer.php, Tools.php), so I just simply copied the files that you posted into that folder - Same with override/controllers/front folder (I copied your AuthController.php file there too) - From within phpMyAdmin (from the old, 1.4 presta install) I exported a few rows of the ps_customer table, into a .csv file - In the new install, I csv imported the previous file (as Customer entity) Still, the old password does not work. Where did I go wrong? Thank a lot, Istvan Derenyi Link to comment Share on other sites More sharing options...
leandro58 Posted February 15, 2014 Share Posted February 15, 2014 i followed this steps but i can't solve this problem.. please help Link to comment Share on other sites More sharing options...
ktapet Posted March 24, 2014 Share Posted March 24, 2014 I made a succesfully customers import incl. passwords(update from ps_1.3.7 to ps_1.6) with some additions to Gonebdg post: I don't know why, but Prestashop Developers wants to re-encrypt the passwords from the csv file. The encription is make in line 2323 from customerImport method of AdminImportController.php and the code is: ******* if ($customer->passwd) $customer->passwd = Tools::encrypt($customer->passwd); ******* The solution i founded was to comment those 2 lines and let the passwords as they are extracted from the old prestashop database in the csv file, where was added already encrypted when customers created their accounts. To do that I overrided AdminImportController.php by adding overide/controllers/admin/AdminImportController.php with the following code on it: *********************************** <?phpclass AdminImportController extends AdminImportControllerCore{ public function customerImport() { $customer_exist = false; $this->receiveTab(); $handle = $this->openCsvFile(); $default_language_id = (int)Configuration::get('PS_LANG_DEFAULT'); $id_lang = Language::getIdByIso(Tools::getValue('iso_lang')); if (!Validate::isUnsignedId($id_lang)) $id_lang = $default_language_id; AdminImportController::setLocale(); for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) { if (Tools::getValue('convert')) $line = $this->utf8EncodeArray($line); $info = AdminImportController::getMaskedRow($line); AdminImportController::setDefaultValues($info); if (Tools::getValue('forceIDs') && isset($info['id']) && (int)$info['id']) $customer = new Customer((int)$info['id']); else { if (array_key_exists('id', $info) && (int)$info['id'] && Customer::customerIdExistsStatic((int)$info['id'])) $customer = new Customer((int)$info['id']); else $customer = new Customer(); } if (array_key_exists('id', $info) && (int)$info['id'] && Customer::customerIdExistsStatic((int)$info['id'])) { $current_id_customer = $customer->id; $current_id_shop = $customer->id_shop; $current_id_shop_group = $customer->id_shop_group; $customer_exist = true; $customer_groups = $customer->getGroups(); $addresses = $customer->getAddresses((int)Configuration::get('PS_LANG_DEFAULT')); } // Group Importation if (isset($info['group']) && !empty($info['group'])) { foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group) { $group = trim($group); if(empty($group)) continue; $id_group = false; if (is_numeric($group) && $group) { $myGroup = new Group((int)$group); if (Validate::isLoadedObject($myGroup)) $customer_groups[] = (int)$group; continue; } $myGroup = Group::searchByName($group); if (isset($myGroup['id_group']) && $myGroup['id_group']) $id_group = (int)$myGroup['id_group']; if (!$id_group) { $myGroup = new Group(); $myGroup->name = Array($id_lang => $group); if ($id_lang != $default_language_id) $myGroup->name = $myGroup->name + array($default_language_id => $group); $myGroup->price_display_method = 1; $myGroup->add(); if (Validate::isLoadedObject($myGroup)) $id_group = (int)$myGroup->id; } if ($id_group) $customer_groups[] = (int)$id_group; } } elseif(empty($info['group']) && isset($customer->id) && $customer->id) $customer_groups = array(0 => Configuration::get('PS_CUSTOMER_GROUP')); AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $customer); //if ($customer->passwd) //$customer->passwd = Tools::encrypt($customer->passwd); $id_shop_list = explode($this->multiple_value_separator, $customer->id_shop); $customers_shop = array(); $customers_shop['shared'] = array(); $default_shop = new Shop((int)Configuration::get('PS_SHOP_DEFAULT')); if (Shop::isFeatureActive() && $id_shop_list) { foreach ($id_shop_list as $id_shop) { if (empty($id_shop)) continue; $shop = new Shop((int)$id_shop); $group_shop = $shop->getGroup(); if ($group_shop->share_customer) { if (!in_array($group_shop->id, $customers_shop['shared'])) $customers_shop['shared'][(int)$id_shop] = $group_shop->id; } else $customers_shop[(int)$id_shop] = $group_shop->id; } } else { $default_shop = new Shop((int)Configuration::get('PS_SHOP_DEFAULT')); $default_shop->getGroup(); $customers_shop[$default_shop->id] = $default_shop->getGroup()->id; } //set temporally for validate field $customer->id_shop = $default_shop->id; $customer->id_shop_group = $default_shop->getGroup()->id; if (isset($info['id_default_group']) && !empty($info['id_default_group']) && !is_numeric($info['id_default_group'])) { $info['id_default_group'] = trim($info['id_default_group']); $myGroup = Group::searchByName($info['id_default_group']); if (isset($myGroup['id_group']) && $myGroup['id_group']) $info['id_default_group'] = (int)$myGroup['id_group']; } $myGroup = new Group($customer->id_default_group); if (!Validate::isLoadedObject($myGroup)) $customer->id_default_group = (int)Configuration::get('PS_CUSTOMER_GROUP'); $customer_groups[] = (int)$customer->id_default_group; $customer_groups = array_flip(array_flip($customer_groups)); $res = true; if (($field_error = $customer->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $customer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) { foreach ($customers_shop as $id_shop => $id_group) { if ($id_shop == 'shared') { foreach ($id_group as $key => $id) { $customer->id_shop = (int)$key; $customer->id_shop_group = (int)$id; if ($customer_exist && ($current_id_shop_group == $id || in_array($current_id_shop, ShopGroup::getShopsFromGroup($id)))) { $customer->id = $current_id_customer; $res &= $customer->update(); } else { $res &= $customer->add(); if (isset($addresses)) foreach ($addresses as $address) { $address['id_customer'] = $customer->id; unset($address['country'], $address['state'], $address['state_iso'], $address['id_address'] ); Db::getInstance()->insert('address', $address); } } if ($res && isset($customer_groups)) $customer->updateGroup($customer_groups); } } else { $customer->id_shop = $id_shop; $customer->id_shop_group = $id_group; if ($customer_exist && $id_shop == $current_id_shop) { $customer->id = $current_id_customer; $res &= $customer->update(); } else { $res &= $customer->add(); if (isset($addresses)) foreach ($addresses as $address) { $address['id_customer'] = $customer->id; unset($address['country'], $address['state'], $address['state_iso'], $address['id_address']); Db::getInstance()->insert('address', $address); } } if ($res && isset($customer_groups)) $customer->updateGroup($customer_groups); } } } unset($customer_groups); $customer_exist = false; if (!$res) { $this->errors[] = sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $info['email'], (isset($info['id']) && !empty($info['id']))? $info['id'] : 'null' ); $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); } } $this->closeCsvFile($handle); } } *********************************** 1 Link to comment Share on other sites More sharing options...
seowebmaster Posted March 25, 2014 Share Posted March 25, 2014 I tried the ktapet solution... not working! I added the file override/controllers/admin/AdminImportController.php with the code mentioned, but the hashed password is still encrypted. Link to comment Share on other sites More sharing options...
ktapet Posted March 26, 2014 Share Posted March 26, 2014 (edited) I tried the ktapet solution... not working! I added the file override/controllers/admin/AdminImportController.php with the code mentioned, but the hashed password is still encrypted. did you delete the /cache/class_index.php file after you add override/controllers/admin/AdminImportController.php file? Edited March 26, 2014 by ktapet (see edit history) Link to comment Share on other sites More sharing options...
seowebmaster Posted March 26, 2014 Share Posted March 26, 2014 did you delete the /cache/class_index.php file after you add override/controllers/admin/AdminImportController.php file? I deleted it now.. the hashed code remains the same, but I cannot login anyway. Does it have to do with the secure key or something? Link to comment Share on other sites More sharing options...
ilovekutchi.com Posted April 8, 2014 Share Posted April 8, 2014 Edit file ../config/settings.inc.php , and add : define('_COOKIE_KEY_OLD_', 'YOUR_PS_V.1.4.9_COOKIE_KEY_');Edit file ../override/classes/Customer.php, and add : public function getByEmail_old($email, $passwd = null, $ignore_guest = true) { if (!Validate::isEmail($email) || ($passwd && !Validate::isPasswd($passwd))) die (Tools::displayError()); $sql = 'SELECT * FROM `'._DB_PREFIX_.'customer` WHERE `email` = \''.pSQL($email).'\' '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).' '.(isset($passwd) ? 'AND `passwd` = \''.Tools::encrypt_old($passwd).'\'' : '').' AND `deleted` = 0'. ($ignore_guest ? ' AND `is_guest` = 0' : ''); $result = Db::getInstance()->getRow($sql); if (!$result) return false; $this->id = $result['id_customer']; foreach ($result as $key => $value) if (key_exists($key, $this)) $this->{$key} = $value; return $this; } Edit file ../override/classes/Tools.php, and add : public static function encrypt_old($passwd) { return md5(_COOKIE_KEY_OLD_.$passwd); }Edit file ../override/controllers/front/AuthController.php, and add : protected function processSubmitLogin() { Hook::exec('actionBeforeAuthentication'); $passwd = trim(Tools::getValue('passwd')); $email = trim(Tools::getValue('email')); if (empty($email)) $this->errors[] = Tools::displayError('E-mail address required'); elseif (!Validate::isEmail($email)) $this->errors[] = Tools::displayError('Invalid e-mail 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)); $authentication_old = $customer->getByEmail_old(trim($email), trim($passwd)); if ((!$authentication AND !$authentication_old) || !$customer->id) $this->errors[] = Tools::displayError('Authentication failed'); else { $this->context->cookie->id_compare = isset($this->context->cookie->id_compare) ? $this->context->cookie->id_compare: CompareProduct::getIdCompareByIdCustomer($customer->id); $this->context->cookie->id_customer = (int)($customer->id); $this->context->cookie->customer_lastname = $customer->lastname; $this->context->cookie->customer_firstname = $customer->firstname; $this->context->cookie->logged = 1; $customer->logged = 1; $this->context->cookie->is_guest = $customer->isGuest(); $this->context->cookie->passwd = $customer->passwd; $this->context->cookie->email = $customer->email; // Add customer to the context $this->context->customer = $customer; if (Configuration::get('PS_CART_FOLLOWING') && (empty($this->context->cookie->id_cart) || Cart::getNbProducts($this->context->cookie->id_cart) == 0)) $this->context->cookie->id_cart = (int)Cart::lastNoneOrderedCart($this->context->customer->id); // Update cart address $this->context->cart->id = $this->context->cookie->id_cart; $this->context->cart->setDeliveryOption(null); $this->context->cart->id_address_delivery = Address::getFirstCustomerAddressId((int)($customer->id)); $this->context->cart->id_address_invoice = Address::getFirstCustomerAddressId((int)($customer->id)); $this->context->cart->secure_key = $customer->secure_key; $this->context->cart->update(); $this->context->cart->autosetProductAddress(); Hook::exec('actionAuthentication'); // Login information have changed, so we check if the cart rules still apply CartRule::autoRemoveFromCart($this->context); CartRule::autoAddToCart($this->context); if (!$this->ajax) { if ($back = Tools::getValue('back')) Tools::redirect(html_entity_decode($back)); Tools::redirect('index.php?controller=my-account'); } } } if ($this->ajax) { $return = array( 'hasError' => !empty($this->errors), 'errors' => $this->errors, 'token' => Tools::getToken(false) ); die(Tools::jsonEncode($return)); } else $this->context->smarty->assign('authentification_error', $this->errors); } Finallycreate csv file to update XX_customer_group table database for all id_customer set group to 3 (customer), and import to your Prestashop database Done It worked for me! version 1.3.2 -> 1.5.6 (my new site is not online yet, but all the test I did indicate that these changes worked). Many thanks gonebdg!! PS: don't forget to change "'YOUR_PS_V.1.4.9_COOKIE_KEY_'" by your cookie key located in the "old" ../config/settings.inc.php Also, don't forget to delete /cache/class_index.php file Link to comment Share on other sites More sharing options...
seowebmaster Posted April 9, 2014 Share Posted April 9, 2014 It worked for me! version 1.3.2 -> 1.5.6 (my new site is not online yet, but all the test I did indicate that these changes worked). Many thanks gonebdg!! I tried exactly the same thing (I am running v1.6), but when I upload the Customer.php and Tools.php file I get only blank pages (both in FO and BO)... PS. I did replace the old secure key and deleted the class_index.php Link to comment Share on other sites More sharing options...
bellini13 Posted April 9, 2014 Share Posted April 9, 2014 edit config/defines.inc.php change the following line define('_PS_MODE_DEV_', false); to.. define('_PS_MODE_DEV_', true); Then try again and let us know what the error message is Link to comment Share on other sites More sharing options...
seowebmaster Posted April 9, 2014 Share Posted April 9, 2014 edit config/defines.inc.php change the following line define('_PS_MODE_DEV_', false); to.. define('_PS_MODE_DEV_', true); Then try again and let us know what the error message is Fatal error: Call to undefined method Tools::isPHPCLI() in ~/config/config.inc.php on line 64 Link to comment Share on other sites More sharing options...
bellini13 Posted April 9, 2014 Share Posted April 9, 2014 When you uploaded Tools and Customer files, which directory did you upload them to? Link to comment Share on other sites More sharing options...
seowebmaster Posted April 10, 2014 Share Posted April 10, 2014 When you uploaded Tools and Customer files, which directory did you upload them to? ~/override/classes/ PS.: working with PS 1.6 Link to comment Share on other sites More sharing options...
bellini13 Posted April 10, 2014 Share Posted April 10, 2014 ~/override/classes/ PS.: working with PS 1.6 Ok, so you are past your original error then? Link to comment Share on other sites More sharing options...
seowebmaster Posted April 10, 2014 Share Posted April 10, 2014 Ok, so you are past your original error then? I probably have another error... When I go to my account page, the page is blank, but not entirely; I can see the header, sidebar and footer. I've set.. define('_PS_DISPLAY_COMPATIBILITY_WARNING_', false); and @ini_set('display_errors', 'on'); but no error is shown... Link to comment Share on other sites More sharing options...
seowebmaster Posted April 14, 2014 Share Posted April 14, 2014 Ok, so you are past your original error then? If I upload those two files I get this Fatal error: Call to undefined method Tools::isPHPCLI() in ~/public_html/config/config.inc.php on line 64 Link to comment Share on other sites More sharing options...
Rha-pt Posted June 25, 2014 Share Posted June 25, 2014 to 1.6 Edit file ../config/settings.inc.php , and add : define('_COOKIE_KEY_OLD_', 'YOUR_PS_V.1.4.9_COOKIE_KEY_'); Edit file /controllers/front/Customer.php, and change : public function getByEmail($email, $passwd = null, $ignore_guest = true) { if (!Validate::isEmail($email) || ($passwd && !Validate::isPasswd($passwd))) die (Tools::displayError()); $sql = 'SELECT * FROM `'._DB_PREFIX_.'customer` WHERE `email` = \''.pSQL($email).'\' '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).' '.(isset($passwd) ? 'AND (`passwd` = \''.Tools::encrypt($passwd).'\' OR `passwd` = \''.Tools::encrypt_old($passwd).'\')' : '').' AND `deleted` = 0'. ($ignore_guest ? ' AND `is_guest` = 0' : ''); $result = Db::getInstance()->getRow($sql); if (!$result) return false; $this->id = $result['id_customer']; foreach ($result as $key => $value) if (key_exists($key, $this)) $this->{$key} = $value; return $this; } Edit file /controllers/front/Tools.php, and add : public static function encrypt_old($passwd) { return md5(_COOKIE_KEY_OLD_.$passwd); } Edit file : /controllers/front/IdentityController.php and change : public function postProcess() { $origin_newsletter = (bool)$this->customer->newsletter; if (Tools::isSubmit('submitIdentity')) { $email = trim(Tools::getValue('email')); if (Tools::getValue('months') != '' && Tools::getValue('days') != '' && Tools::getValue('years') != '') $this->customer->birthday = (int)(Tools::getValue('years')).'-'.(int)(Tools::getValue('months')).'-'.(int)(Tools::getValue('days')); elseif (Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '') $this->customer->birthday = null; else $this->errors[] = Tools::displayError('Invalid date of birth.'); if (Tools::getIsset('old_passwd')) $old_passwd = trim(Tools::getValue('old_passwd')); if (!Validate::isEmail($email)) $this->errors[] = Tools::displayError('This email address is not valid'); elseif ($this->customer->email != $email && Customer::customerExists($email, true)) $this->errors[] = Tools::displayError('An account using this email address has already been registered.'); elseif (!Tools::getIsset('old_passwd') || (Tools::encrypt($old_passwd) != $this->context->cookie->passwd && Tools::encrypt_old($old_passwd) != $this->context->cookie->passwd)) $this->errors[] = Tools::displayError('The password you entered is incorrect.'); elseif (Tools::getValue('passwd') != Tools::getValue('confirmation')) $this->errors[] = Tools::displayError('The password and confirmation do not match.'); else { $prev_id_default_group = $this->customer->id_default_group; // Merge all errors of this file and of the Object Model $this->errors = array_merge($this->errors, $this->customer->validateController()); } if (!count($this->errors)) { $this->customer->id_default_group = (int)$prev_id_default_group; $this->customer->firstname = Tools::ucwords($this->customer->firstname); if (Configuration::get('PS_B2B_ENABLE')) { $this->customer->website = Tools::getValue('website'); // force update of website, even if box is empty, this allows user to remove the website $this->customer->company = Tools::getValue('company'); } if (!Tools::getIsset('newsletter')) $this->customer->newsletter = 0; elseif (!$origin_newsletter && Tools::getIsset('newsletter')) if ($module_newsletter = Module::getInstanceByName('blocknewsletter')) if ($module_newsletter->active) $module_newsletter->confirmSubscription($this->customer->email); if (!Tools::getIsset('optin')) $this->customer->optin = 0; if (Tools::getValue('passwd')) $this->context->cookie->passwd = $this->customer->passwd; if ($this->customer->update()) { $this->context->cookie->customer_lastname = $this->customer->lastname; $this->context->cookie->customer_firstname = $this->customer->firstname; $this->context->smarty->assign('confirmation', 1); } else $this->errors[] = Tools::displayError('The information cannot be updated.'); } } else $_POST = array_map('stripslashes', $this->customer->getFields()); return $this->customer; } Link to comment Share on other sites More sharing options...
bangweha Posted October 15, 2014 Share Posted October 15, 2014 Edit file ../config/settings.inc.php , and add : define('_COOKIE_KEY_OLD_', 'YOUR_PS_V.1.4.9_COOKIE_KEY_');Edit file ../override/classes/Customer.php, and add : public function getByEmail_old($email, $passwd = null, $ignore_guest = true) { if (!Validate::isEmail($email) || ($passwd && !Validate::isPasswd($passwd))) die (Tools::displayError()); $sql = 'SELECT * FROM `'._DB_PREFIX_.'customer` WHERE `email` = \''.pSQL($email).'\' '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).' '.(isset($passwd) ? 'AND `passwd` = \''.Tools::encrypt_old($passwd).'\'' : '').' AND `deleted` = 0'. ($ignore_guest ? ' AND `is_guest` = 0' : ''); $result = Db::getInstance()->getRow($sql); if (!$result) return false; $this->id = $result['id_customer']; foreach ($result as $key => $value) if (key_exists($key, $this)) $this->{$key} = $value; return $this; } Edit file ../override/classes/Tools.php, and add : public static function encrypt_old($passwd) { return md5(_COOKIE_KEY_OLD_.$passwd); }Edit file ../override/controllers/front/AuthController.php, and add : protected function processSubmitLogin() { Hook::exec('actionBeforeAuthentication'); $passwd = trim(Tools::getValue('passwd')); $email = trim(Tools::getValue('email')); if (empty($email)) $this->errors[] = Tools::displayError('E-mail address required'); elseif (!Validate::isEmail($email)) $this->errors[] = Tools::displayError('Invalid e-mail 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)); $authentication_old = $customer->getByEmail_old(trim($email), trim($passwd)); if ((!$authentication AND !$authentication_old) || !$customer->id) $this->errors[] = Tools::displayError('Authentication failed'); else { $this->context->cookie->id_compare = isset($this->context->cookie->id_compare) ? $this->context->cookie->id_compare: CompareProduct::getIdCompareByIdCustomer($customer->id); $this->context->cookie->id_customer = (int)($customer->id); $this->context->cookie->customer_lastname = $customer->lastname; $this->context->cookie->customer_firstname = $customer->firstname; $this->context->cookie->logged = 1; $customer->logged = 1; $this->context->cookie->is_guest = $customer->isGuest(); $this->context->cookie->passwd = $customer->passwd; $this->context->cookie->email = $customer->email; // Add customer to the context $this->context->customer = $customer; if (Configuration::get('PS_CART_FOLLOWING') && (empty($this->context->cookie->id_cart) || Cart::getNbProducts($this->context->cookie->id_cart) == 0)) $this->context->cookie->id_cart = (int)Cart::lastNoneOrderedCart($this->context->customer->id); // Update cart address $this->context->cart->id = $this->context->cookie->id_cart; $this->context->cart->setDeliveryOption(null); $this->context->cart->id_address_delivery = Address::getFirstCustomerAddressId((int)($customer->id)); $this->context->cart->id_address_invoice = Address::getFirstCustomerAddressId((int)($customer->id)); $this->context->cart->secure_key = $customer->secure_key; $this->context->cart->update(); $this->context->cart->autosetProductAddress(); Hook::exec('actionAuthentication'); // Login information have changed, so we check if the cart rules still apply CartRule::autoRemoveFromCart($this->context); CartRule::autoAddToCart($this->context); if (!$this->ajax) { if ($back = Tools::getValue('back')) Tools::redirect(html_entity_decode($back)); Tools::redirect('index.php?controller=my-account'); } } } if ($this->ajax) { $return = array( 'hasError' => !empty($this->errors), 'errors' => $this->errors, 'token' => Tools::getToken(false) ); die(Tools::jsonEncode($return)); } else $this->context->smarty->assign('authentification_error', $this->errors); } Finallycreate csv file to update XX_customer_group table database for all id_customer set group to 3 (customer), and import to your Prestashop database Done i just followed your post. and now i cant access FO and BO on my local server. the error message is Fatal error: Class 'ToolsCore' not found in C:\wamp\www\mysite\override\classes\Tools.php on line 4. Kindly your help.. Thank you Link to comment Share on other sites More sharing options...
bellini13 Posted October 15, 2014 Share Posted October 15, 2014 show us the content of /override/classes/Tools.php Link to comment Share on other sites More sharing options...
bangweha Posted October 16, 2014 Share Posted October 16, 2014 show us the content of /override/classes/Tools.php <?php class Tools extends ToolsCore { public static function encrypt_old($passwd) { return md5(_COOKIE_KEY_OLD_.$passwd); } } Link to comment Share on other sites More sharing options...
bellini13 Posted October 16, 2014 Share Posted October 16, 2014 What version of Prestashop are you using? Did you confirm that this file also exists and that you have not made any changes to it? /classes/Tools.php Link to comment Share on other sites More sharing options...
daybydayx Posted October 16, 2014 Share Posted October 16, 2014 Done 1.4.11 to 1.5.4 works fine. Thank you. Link to comment Share on other sites More sharing options...
bangweha Posted October 17, 2014 Share Posted October 17, 2014 What version of Prestashop are you using? Did you confirm that this file also exists and that you have not made any changes to it? /classes/Tools.php Yes i did. i put Tools.php in override/classes. and i didn't make any changes PS 1.6 Link to comment Share on other sites More sharing options...
bellini13 Posted October 17, 2014 Share Posted October 17, 2014 You are trying to implement a solution designed for v1.5 in v1.6? Link to comment Share on other sites More sharing options...
gonebdg - webindoshop.com Posted October 18, 2014 Share Posted October 18, 2014 (edited) Basic understanding for customer migrations from the old to new Prestashop versions is :The customers data on your old prestashop version are using different Cookie Key. This Cookie Key is defined as PHP Constan variable _COOKIE_KEY_Customers password hash and secure key will be different if the _COOKIE_KEY_ is differentModification should be working well for PS v1.1 - PS v1.5 to PS v1.6because there is no major different in password encryption method md5(_COOKIE_KEY_.$passwd); Therefore you will need to modified you Prestashop, so the old _COOKIE_KEY_ is able to be used for authentication.BUT if your new Prestashop is a clean install Prestashop and there are no customers data yet, then it's not necessary to modify your Prestashop (override the classes and controller files).What You have to do is :Change the value of constan var _COOKIE_KEY_ which defined on your new Prestashop (@ config/settings.inc.php) with the old value of _COOKIE_KEY_ on your old Prestashop version.That's all ... But for those who still need modifications, you can found and use the necessary files attached in here : Customers data migration.zip Instructions : Extract the compressed file to your computer directory and Upload folder /override/ (with all folder and files contained) to your Prestashop installation directory From your old Prestashop, open file config/settings.inc.php From your new Prestashop, open file config/settings.inc.php and add : define('_COOKIE_KEY_OLD_', '_YOUR_OLD_COOKIE_KEY_'); Change _YOUR_OLD_COOKIE_KEY_ with value of _COOKIE_KEY_ from your old Prestashop Save modifications Prepare your customer and customer_group database file Depend on your old Prestashop version, You might have to adjust the corresponding value with DB column. Therefore i suggest to use Ms.Excel to create customer and customer_group database file in *.csv file format Import all customers data from your old Prestashop to new Prestashop database (DB table PREFIX_customer and PREFIX_customer_group ) DONE Edited October 18, 2014 by gonebdg - webindoshop.com (see edit history) Link to comment Share on other sites More sharing options...
trevorgilligan Posted April 1, 2015 Share Posted April 1, 2015 just wondering can anyone help? im getting this error: Fatal error: Class 'ToolsCore' not found in /var/www/web/shop3/tools/profiling/Tools.php on line 28 . site is http://4u.ie/shop3 . i have renamed and renamed back to original name /classes/Tools.php and Currency.php (so no changes). V upset about this, such a small thing and has taken up nearly the day Link to comment Share on other sites More sharing options...
ajaykumarsingh395 Posted November 19, 2015 Share Posted November 19, 2015 Moving customers passwords to new site 1.2.4.0->1.6.1.1 Hello, I was trying to upgrade my 1.2.4.0 to 1.6.1.1 . I created a new site and migrated all the data using a payed service. All is well except for the customers passwords. The recomendation is for the customer to have to create a new password using the link. This is not something I want my customers to go through and if it was me I might have cancelled my order if I couldnt log in. So I'm trying to move the salt and hashes and all that stuff from my old installation. Just moving COOKIE_KEY and COOKIE_IV doesnt help and then I cant login to the admin site either. How Can i do in 1.6.1.1 version. Link to comment Share on other sites More sharing options...
nosnevetzy Posted December 15, 2015 Share Posted December 15, 2015 I'm also facing this problem today. Please help. I tried the solution of @gonebdg but It doesn't work. I'm trying to migrate my customers from PS 1.4.7 to PS 1.6.0.14. Please help! Link to comment Share on other sites More sharing options...
nosnevetzy Posted December 16, 2015 Share Posted December 16, 2015 Please help! Link to comment Share on other sites More sharing options...
lagoacity Posted October 25, 2016 Share Posted October 25, 2016 Hi i have a problem with Customer Password I bought a module leading to migrate customer data, but they can not access the website because it does not accept the password. Here two information of the installation document, but when I do what it says in the document it blocks access to the BO, can someone help me? When the migration is finished: 1. Step to the root folder of your Source PrestaShop 2. Enter “ config ” folder 3. Open “ settings.inc.php ” file as a text document 4. Copy COOKIE_KEY code After copying COOKIE_KEY code, enter the same directory but on your Target PrestaShop ( /root folder/config/settings.inc.php ) and replace the COOKIE_KEY you see with the one you’ve copied from Source PrestaShop . On this point, the migration of customer passwords is completely finished. The last step would be your admin account password recovery (required for admin accounts only). Click on “ I forget my password ”, enter email and a new password to your admin account will be sent to your email. Link to comment Share on other sites More sharing options...
bellini13 Posted October 25, 2016 Share Posted October 25, 2016 so are you saying that the "forgot my password" feature for the back office does not work, and is not sending you an email to reset the password? Link to comment Share on other sites More sharing options...
lagoacity Posted October 26, 2016 Share Posted October 26, 2016 yes, this last point is that my clients continue to have the same passowrd the old site but I can not this happen, can you help me? Link to comment Share on other sites More sharing options...
bellini13 Posted October 26, 2016 Share Posted October 26, 2016 I bought a module leading to migrate customer data, but they can not access the website because it does not accept the password. If you purchased a module to migrate the data, then why not contact the author of the module who provided you with these non working instructions? Link to comment Share on other sites More sharing options...
lagoacity Posted November 2, 2016 Share Posted November 2, 2016 he can not explain and I also no longer answers me at least to 15 days!! I need my customers to keep the old password as soon as possible Link to comment Share on other sites More sharing options...
bjorn82dk Posted December 29, 2017 Share Posted December 29, 2017 up 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