I have an Yii application, and now I need to revamp this Yii application to Yii 2, and I need to migrate the user table from Yii to Yii2. So how can I migrate the user's password so that user can login to Yii2 without changing password?
Asked
Active
Viewed 370 times
1 Answers
0
You should rewrite two methods in User
model:
/**
* Validates password
*
* @param string $password password to validate
* @return boolean if password provided is valid for current user
*/
public function validatePassword($password)
{
return Yii::$app->security->validatePassword($password, $this->password_hash);
}
/**
* Generates password hash from password and sets it to the model
*
* @param string $password
*/
public function setPassword($password)
{
$this->password_hash = Yii::$app->security->generatePasswordHash($password);
}
Rewrite to your methods from yii1 behavior

Evgeniy Tkachenko
- 1,733
- 1
- 17
- 23