我有两个不同的表user
和organiser
,我试图为两个用户创建2个不同的登录名。yii2中的多登录表登录时出现IdentityInterface错误
我能够轻松地邀请他们参加,并得到记录在数据库中,但保存记录后,我得到下面的代码行
if ($user = $model->signup()) {
if (Yii::$app->getUser()->login($user)) { //yii\web\IdentityInterface error
return $this->goHome();
}
}
继错误是我configuration
模块
'components' => [
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'identityCookie' => [
'name' => '_frontendOrganiser', // unique for frontend
],
],
'users' => [
'class' => 'yii\web\User',
'identityClass' => 'common\models\Users',
'enableAutoLogin' => false,
'enableSession' => true,
'identityCookie' => [
'name' => '_frontendUser', // unique for frontend
],
],
'session' => [
'name' => 'PHPFRONTSESSID',
'savePath' => sys_get_temp_dir(),
],
]
那么,我在这里做什么错了?我是否需要创建任何其他接口或其他东西或为不同的模块提供不同的接口?
,我不得不这样做,因为organiser
表使用password_hash
技术来记录在我的user
表是从其他项目中的用户,他们使用md5
技术,所以我不得不为用户创建单独的模块。
参数1传递给警予\网络\用户::登录()必须警予\网络\ IdentityInterface,共同\型号\给予用户的情况下,称为C的实例:\ XAMPP \ htdocs中\项目\ frontend \ controllers \ SiteController.php 202行,并定义为
确切的错误语句如上。
接口文档是您'$ user'变量的类的对象,'实现警予\网络\ IdentityInterface'? –
@PatrykRadziszewski是的多数民众赞成在它。这是问题所在。但我现在可以登录,但无法通过'Yii :: $ app-> users-> identity-> username'行访问登录用户。 –