I use yii2 for developing web site.
Before save user to db, I encripted password like this:
$this->password = Yii::$app->security->generatePasswordHash($this->password);
And when I use this code:
Yii::$app->security->validatePassword("some string", $this->password);
I have error:
Invalid Parameter – yii\base\InvalidParamException
Hash is invalid.
What is wrong?
I ran into the same issue. I realized that my password field's character capacity was too short for the hash, so I bumped it up from varchar(25) to varchar(255).
make sureyou have a column name exactly as password_hash in the user table and change your code from
Yii::$app->security->validatePassword("some string", $this->password);
to:
Yii::$app->security->validatePassword("some string", $this->password_hash);