Customer password not working after migration from Magento 1 to Magento 2
"The data migration tool takes advantage of such backward compatibility in Magento to automatically migrate Customer password from Magento 1 to Magento 2. So your customers can use their md5()
based password without the need to reset their passwords after migration. "
Meaning they can log in with their md5 password ? I tried, to no avail.
After migrating database from magento1 to magento2, customer login problem occurs, to solve that problem just go to a file name encryptor.php in the vendor folder (Path is below) vendor\magento\framework\Encryption\Encryptor.php and change isValidHash() function like below.
public function isValidHash($password, $hash)
{
try {
$this->explodePasswordHash($hash);
foreach ($this->getPasswordVersion() as $hashVersion) {
if ($hashVersion == '0') {
$recreated = current(explode(':', $hash));
}else if ($hashVersion === self::HASH_VERSION_ARGON2ID13) {
$recreated = $this->getArgonHash($password, $this->getPasswordSalt());
} else {
$recreated = $this->generateSimpleHash($this->getPasswordSalt() . $password, $hashVersion);
}
$hash = $this->getPasswordHash();
error_log('password changing technique ======');
error_log(print_r($recreated,true));
error_log(print_r($hash,true));
}
} catch (\RuntimeException $exception) {
//Hash is not a password hash.
$recreated = $this->hash($password);
}
return Security::compareStrings(
$recreated,
$hash
);
}
the above change wont cause any issue because once user login with above method, magento2 will change the password hash to its proper password format and you can see difference in customer_entity table in magento2 database.