Yii 权限模块使用不同的应用程序实例
我正在开发一个Yii应用程序,它使用几个模块,包括权限模块来进行访问控制。它们都位于相同的“modules”文件夹中,并在相同的config/main.php文件中配置。应用程序只有一个输入脚本 然而,我注意到权限模块使用不同的应用程序会话,而所有其他模块使用另一个应用程序会话。由于这个原因,用户会话不能与权限共享 是否有人在使用yii模块时遇到过此类问题?请帮忙。谢谢 我的配置文件:Yii 权限模块使用不同的应用程序实例,yii,rights,Yii,Rights,我正在开发一个Yii应用程序,它使用几个模块,包括权限模块来进行访问控制。它们都位于相同的“modules”文件夹中,并在相同的config/main.php文件中配置。应用程序只有一个输入脚本 然而,我注意到权限模块使用不同的应用程序会话,而所有其他模块使用另一个应用程序会话。由于这个原因,用户会话不能与权限共享 是否有人在使用yii模块时遇到过此类问题?请帮忙。谢谢 我的配置文件: 'rights'=>array( 'debug' => true,
'rights'=>array(
'debug' => true,
'superuserName' => 'Super Administrator', // Name of the role with super user privileges.
'authenticatedName' => 'Customer', // Name of the authenticated user role.
'userIdColumn' => 'id', // Name of the user id column in the database.
'userNameColumn' => 'username', // Name of the user name column in the database.
'enableBizRule' => true, // Whether to enable authorization item business rules.
'enableBizRuleData' => true, // Whether to enable data for business rules.
'displayDescription' => false, // Whether to use item description instead of name.
'flashSuccessKey' => 'success', // Key to use for setting success flash messages.
'flashErrorKey' => 'error', // Key to use for setting error flash messages.
//'baseUrl' =>'/rights', // Base URL for Rights. Change if module is nested.
//'layout' => 'rights.views.layouts.main', // Layout to use for displaying Rights.
//'appLayout' => 'application.views.layouts.main', // Application layout.
//'cssFile' => 'rights.css', // Style sheet file to use for Rights.
'install' => false, // Whether to enable installer.
),
经过两天的努力,我找到了解决办法 我注意到它在系统中使用了两个不同的键前缀(stateKeyPrefix)。一个用于权限,另一个用于其他模块。可以将其配置为在主配置文件中使用单键前缀
'user'=>array(
'class'=>'RWebUser',
'allowAutoLogin'=>true, // enable cookie-based authentication
'stateKeyPrefix'=>'f298d9729c7408c3d406db95a9639204', // some random value
),
希望这能帮助有同样问题的人。代码可能有问题。你能粘贴一些代码让我判断吗?但我认为不同的会话不是问题,因为根据我的理解,这是不可能的。我认为更可能的是,当您尝试访问权限模块时,它没有被实例化。。。例如,如果在控制器访问规则中,您引用的是用户模块,那么您需要首先确保该模块已被用户标识引用……大家好,谢谢大家的评论。我已经用我的配置细节更新了这个问题。权限模块也包括在系统中作为任何其他模块。奇怪的是,rights使用的是一个完全不同的应用程序实例,而所有其他模块都使用一个通用的应用程序实例。我通过检查应用程序id(Yii::app()->id)确认了这一点