How to check password requirement in Prestashop?

400 views Asked by At

In Prestashop 1.5, the code to check if the customer password has 5 characters is located in Validate.php file and is the following :

    public static function isPasswd($passwd, $size = 5)
{
    return (Tools::strlen($passwd) >= $size && Tools::strlen($passwd) < 255);
}

Would anyone know how to change it, in order to check if the password complies with the five here below rules :

  • at least 8 characters
  • at least one uppercase
  • at least one lowercase
  • at least one special character
  • at least one digit

Thank you any advance for any help in this matter.

Patrick

1

There are 1 answers

0
Krystian Podemski On

In PrestaShop 8, there will be a new password policy with the implementation of zxcvbn. You can see the implementation here: https://github.com/PrestaShop/PrestaShop/pull/28127

You can modify the isPasswd function and implement the checks you need. Here's an example of doing so: Password strength check in PHP

One more thing. This might not be the answer to your original question, but the truth is that if you still use PrestaShop 1.5, you should upgrade as soon as possible.