1. Go to this page and download the library: Download yii2tech/authlog library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use app\models\User;
use yii2tech\authlog\AuthLogLoginFormBehavior;
class LoginForm extends Model
{
public $username;
public $password;
public $rememberMe = true;
public function behaviors()
{
return [
'authLog' => [
'class' => AuthLogLoginFormBehavior::className(),
'findIdentity' => 'findIdentity',
],
];
}
public function findIdentity()
{
return User::findByUsername($this->username);
}
// ...
}
use app\models\User;
use yii2tech\authlog\AuthLogLoginFormBehavior;
class LoginForm extends Model
{
public $username;
public $password;
public $rememberMe = true;
public $verifyCode;
public function behaviors()
{
return [
'authLog' => [
'class' => AuthLogLoginFormBehavior::className(),
'findIdentity' => 'findIdentity',
'verifyRobotAttribute' => 'verifyCode',
'deactivateIdentity' => function ($identity) {
return $this->updateAttributes(['statusId' => User::STATUS_SUSPENDED]);
},
],
];
}
public function rules()
{
return [
[['username', 'password'], '