public function validatePassword($password)
{
if (\Yii::$app->getSecurity()->validatePassword($password, $this->passwordHash)) {
return true;
}
else {
return false;
}
}
public function setPassword($password)
{
$this->passwordHash=\Yii::$app->getSecurity()->generatePasswordHash($password);
}
public function beforeSave($insert)
{
if (parent::beforeSave($insert)) {
if ($this->isNewRecord) {
$this->authKey = \Yii::$app->security->generateRandomString();
$this->setPassword($this->password);
}
return true;
}
return false;
}
}
а если бы заглянули, то увидели, что всё давно за Вас сделано, с применением и password_hash() и password_verify()
'grozzzny\depends\bootstrap4\Bootstrap4Asset',
'grozzzny\depends\bootstrap4\Bootstrap4PluginAsset
<?php
/* @var $this \yii\web\View */
/* @var $content string */
use yii\helpers\Html;
use app\assets\ProfileAsset;
ProfileAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<?php $this->registerCsrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<div class="overlay"></div>
<?=$content?>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
$this->layout="profile";
return $this->render("test",array("data"=>"sadsadas"));
public function validate($attributeNames = NULL, $clearErrors = true)
{
....
}