AndersHelbo Posted September 25, 2014 Share Posted September 25, 2014 Hi I am running Prestashop v. 1.5.6.2 on a webshop. Regarding to the password that the customer chooses when register on the webshop, I want to change the requirements for that. I already made it, so it has to be at least six characters long. Besides that, I want to change the requirements of the content in the password. it has to contain min. one capital letter. Is there a way to change this requirements in the files somewhere? I have looked under .../classes/validation.php but could not change anything else but the number of the characters? Does someone know how to do this? 1 Link to comment Share on other sites More sharing options...
vekia Posted September 25, 2014 Share Posted September 25, 2014 you can achieve it with regular expression: /^([a-z])([A-Z])([\d,.;:])/ (?=.*[a-z]) checks if somewhere in the string is a lowercase character (?=.*[A-Z]) checks if somewhere in the string is a uppercase character (?=.*[\d,.;:]) checks if somewhere in the string is a digit or one of the other characters, add those you want. do you know how to apply it to Validate controller or you need an detailed explanation? Link to comment Share on other sites More sharing options...
AndersHelbo Posted September 25, 2014 Author Share Posted September 25, 2014 you can achieve it with regular expression: /^([a-z])([A-Z])([\d,.;:]).+$/ (?=.*[a-z]) checks if somewhere in the string is a lowercase character (?=.*[A-Z]) checks if somewhere in the string is a uppercase character (?=.*[\d,.;:]) checks if somewhere in the string is a digit or one of the other characters, add those you want. do you know how to apply it to Validate controller or you need an detailed explanation? Thanks. It would be great with some kind of guide, how to implement this into the file. And what about old accounts with passwords which are not validated in the new way? Will they still be able to login with their old passwords? Link to comment Share on other sites More sharing options...
AndersHelbo Posted September 25, 2014 Author Share Posted September 25, 2014 Forgot to say that it is required that both letters and numbers appears in the passwords :-) Link to comment Share on other sites More sharing options...
vekia Posted September 25, 2014 Share Posted September 25, 2014 no, they will not be able to log in with old password but you can remove this: elseif (!Validate::isPasswd($passwd)) $this->errors[] = Tools::displayError('Invalid password.'); from processSubmitLogin() function in controllers/front/AuthController.php give me 5 minutes im going to prepare code :-) Link to comment Share on other sites More sharing options...
vekia Posted September 25, 2014 Share Posted September 25, 2014 /** * Check for password validity for capitals * * @param string $passwd Password to validate * @return boolean Validity is ok or not * @author VEKIA :-) http://MyPresta.eu */ public static function isPasswdPro($passwd){ if (preg_match('/[A-Z]/',$passwd)){ return true; } else { return false; } } /** * Check for password validity * * @param string $passwd Password to validate * @param int $size * @return boolean Validity is ok or not */ public static function isPasswd($passwd, $size = Validate::PASSWORD_LENGTH){ if ((Tools::strlen($passwd) >= $size && Tools::strlen($passwd) < 255) && Validate::isPasswdPro($passwd)){ return true; } else { return false; } } i modified main isPasswd function - added there if condition to check if isPasswdPro returns true. in this case this function checks Capitals in password 2 Link to comment Share on other sites More sharing options...
vekia Posted September 25, 2014 Share Posted September 25, 2014 if you want more stuff, like special chars, numbers etc. just let me know i love topics like that 2 Link to comment Share on other sites More sharing options...
Paulito Posted October 7, 2014 Share Posted October 7, 2014 Hello Just picked this topic up from a topic posted today. What code would I need if I wanted a customers password to be: Minimum 8 charactors Contain at least 1 lowercase letter Contain at least 1 uppercase letter Contain at least 1 symbol (+×#@!/%&€£*,: etc Also, what type of password would a customer get if they click the "forgot your password" link This could be a great tutorial Paul Link to comment Share on other sites More sharing options...
vekia Posted October 8, 2014 Share Posted October 8, 2014 it will be necessary to extend if condition that i created: if (preg_match('/[A-Z]/',$passwd)){ to something like: http://pastebin.com/iwNQgSSG sorry i cant save code here as post :/ Link to comment Share on other sites More sharing options...
jaychennai Posted October 21, 2014 Share Posted October 21, 2014 this doesnt seem to work, seems like it works the opposite way for me Link to comment Share on other sites More sharing options...
jaychennai Posted October 21, 2014 Share Posted October 21, 2014 i get 500 errror now Link to comment Share on other sites More sharing options...
J.Sahu Posted December 31, 2014 Share Posted December 31, 2014 (edited) Well I got a different situation. I want to validate the password field for upper case, lower case, number and special character so I have configured my validate.php. The customer part is working good. But the Admin doesn't load and shows an array when I activate the developer mode. case 1: I investigated and found that isPasswdAdmin() also calls the isPasswd () and my admin password doesn't satisfy that condition. So I renamed the isPasswd() inside isPasswdAdmin() and added a new method with the older isPasswd() content. That didn't work. Again case2: Changed my admin password to satisfy the isPasswd() but still that doesn't work. Any solution guys ? I couldn't post the lines due to special characters. SO I'm attaching a file with my code. Validate.php Edited December 31, 2014 by J.Sahu (see edit history) Link to comment Share on other sites More sharing options...
ujwal Posted December 8, 2015 Share Posted December 8, 2015 if you want more stuff, like special chars, numbers etc. just let me know i love topics like that Hi Vekia, Thank you so much for your help. I have got the error in 1.6 after changing when I validate everything and it redirect another page and it said 500 Server ErrorOops, something went wrong. Try to refresh this page or feel free to contact us if the problem persists. Please Help me. THanks Link to comment Share on other sites More sharing options...
pawfad Posted April 15, 2016 Share Posted April 15, 2016 Hi, is it any sollution for "500"? Your code, vekia, seems to be correct, error appears only when conditions are fulfilled. I have got: [PrestaShopException]Property Customer->passwd is not validat line 909 in file classes/ObjectModel.php 904. }905. 906. $message = $this->validateField($field, $this->$field);907. if ($message !== true) {908. if ($die) {909. throw new PrestaShopException($message);910. }911. return $error_return ? $message : false;912. }913. }914. ObjectModelCore->validateFields - [line 246 - classes/ObjectModel.php] ObjectModelCore->getFields - [line 487 - classes/ObjectModel.php] ObjectModelCore->add - [line 229 - classes/Customer.php] - [2 Arguments] CustomerCore->add - [line 588 - controllers/front/AuthController.php] AuthControllerCore->processSubmitAccount - [line 256 - controllers/front/AuthController.php] AuthControllerCore->postProcess - [line 178 - classes/controller/Controller.php] ControllerCore->run - [line 367 - classes/Dispatcher.php] DispatcherCore->dispatch - [line 28 - index.php] [PrestaShop 1.6.1.4] Can anyone help? Thanks in advance. Link to comment Share on other sites More sharing options...
thrashbwoy Posted April 8, 2019 Share Posted April 8, 2019 On 9/25/2014 at 7:39 AM, vekia said: /** * Check for password validity for capitals * * @param string $passwd Password to validate * @return boolean Validity is ok or not * @author VEKIA :-) http://MyPresta.eu */ public static function isPasswdPro($passwd){ if (preg_match('/[A-Z]/',$passwd)){ return true; } else { return false; } } /** * Check for password validity * * @param string $passwd Password to validate * @param int $size * @return boolean Validity is ok or not */ public static function isPasswd($passwd, $size = Validate::PASSWORD_LENGTH){ if ((Tools::strlen($passwd) >= $size && Tools::strlen($passwd) < 255) && Validate::isPasswdPro($passwd)){ return true; } else { return false; } } i modified main isPasswd function - added there if condition to check if isPasswdPro returns true. in this case this function checks Capitals in password I can see that option is for login, but not for register. Im looking for a solution for check strong passwords on register form. Link to comment Share on other sites More sharing options...
chinachin Posted May 21, 2020 Share Posted May 21, 2020 (edited) I am making the same mistake, have you fixed it? help me? It's really troublesome word counter Edited May 27, 2020 by chinachin (see edit history) Link to comment Share on other sites More sharing options...
ecommerce16 Posted May 2, 2021 Share Posted May 2, 2021 4 uren geleden, depthworld zei: Good information I also go through the same problem hope it's help out. [email protected] Please post a new post about this with all the required information, you're responding to a post from 7 years ago, prestashop has changed multiple times since then. Share your PS version etc. and post a new post. Link to comment Share on other sites More sharing options...
Recommended Posts