gpt4 book ai didi

yii2 - 配置 Yii2 中的多个用户身份

转载 作者:行者123 更新时间:2023-12-04 03:13:05 25 4
gpt4 key购买 nike

我开发了一个具有两个不同注册的站点,并且我有 2 个不同的表,我使用 RbacDB,并且在组件部分的 web 配置中我有用户配置,据此我想知道如何使用 2 个不同的配置文件中的字段?

配置:

'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => '213h2i3121h12osiajls',
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'user' => [
'identityClass' => 'app\models\User',
'enableAutoLogin' => true,
],
// Here after user I need to add another config user-two
'user-two' => [
'identityClass' => 'app\models\SecondUser',
'enableAutoLogin' => true,
],

当我这样做时,显示此错误 enter image description here

谢谢!

最佳答案

尝试在用户二组件中设置一个类属性:

'user-two' => [
'class' => 'yii\web\User'
'identityClass' => 'app\models\SecondUser',
'enableAutoLogin' => true,
],

或创建继承自 yii\web\User 类的新类并设置如下:

'user-two' => [
'class' => 'app\models\NewClassInheritedFromUserClass'
....
]

也许这会对你有所帮助。

关于yii2 - 配置 Yii2 中的多个用户身份,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35254678/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com