AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
### 用户认证 config/web.php指定模型, 该模型需要继承ActiveRecord 实现 yii\web\IdentityInterface 接口. 并且需要对里面的方法进行修改. ``` 'user' => [ 'identityClass' => 'app\models\User', 'enableAutoLogin' => true, //是否开启cookie ], ``` User类 : ``` <?php namespace app\models; use yii\db\ActiveRecord; use yii\web\IdentityInterface; class User extends ActiveRecord implements IdentityInterface { public $authKey; public function rules() { return [ [['username', 'password', 'email'], 'safe'] ]; } public static function findIdentity($id) { return static::findOne($id); } public static function findIdentityByAccessToken($token, $type = null) { return static::findOne(['access_token' => $token]); } public static function findByUsername($username) { } public function getId() { return $this->id; } public function getAuthKey() { return $this->authKey; } public function validateAuthKey($authKey) { return $this->authKey === $authKey; } public function validatePassword($password) { return $this->password === $password; } } ```