- 工作我有雇员表,其结构如下:
EMPID
姓
名字
用户名
密码验证未在yii2
现在在应用程序组件中,我已经包含了我的自定义类,如下所示:
'用户'=> [ 'identityClass'=> '应用程序\模型\雇员', 'enableSession'=>真, ],
我已经实现在雇员模型FOLL方法如下:
public static function findIdentityByAccessToken($ token,$ type = null) { throw new NotSupportedException(); }
public function getId() { return $ this-> EmpId; }
public function getAuthKey() throw new NotSupportedException(); }
public function validateAuthKey($ authKey) { throw new NotSupportedException(); }
公共静态函数findByUsername($用户名) { 返回自:: findOne([ '用户名'=> $用户名]); }
public function validatePassword($ password) { return $ this-> Password === $ password; }
而在LoginForm模型中,我有以下内容。用户,我已包括 自定义类员工。
公共功能的getUser() { 如果($这 - > _用户===假) { $这 - > _用户=雇员:: findByUsername($这个 - >用户名); }
return $this->_user;
}
现在,当我尝试登录,并提供用户名和密码,它提供了FOLL错误:
财产来源不明 - 警予\基地\ UnknownPropertyException
未知财产:app \ models \ Employee ::用户名