我是新来的。根据文档,我将yii-rights安装在protected/modules/rights中。但不能正确使用。有一些我找不到的东西。localhost/index.php/right页面工作正常。但当我按下“权限”、“角色”、“任务”、“操作”时。它显示了
“错误403您无权执行此操作。”
下面是我的主要配置::
'import'=>array(
'application.modules.right.*',
'application.modules.right.models*',
'application.modules.rights.components.*',
),
'rights'=>array(
'superuserName'=>'Admin', // Name of the role with super user privileges.
'authenticatedName'=>'Authenticated', // 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'=>false, // Whether to enable data for business rules.
'displayDescription'=>true, // Whether to use item description instead of name.
'flashSuccessKey'=>'RightsSuccess', // Key to use for setting success flash messages.
'flashErrorKey'=>'RightsError', // 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.
'debug'=>false,
),
'components'=>array(
'user'=>array(
'class'=>'RWebUser',
// enable cookie-based authentication
'allowAutoLogin'=>true,
'loginUrl'=>array('/user/login'),
),AssignementController
public function accessRules()
{
return array(
array('allow', // Allow superusers to access Rights
'actions'=>array(
'view',
'user',
'revoke',
),
'users'=>$this->_authorizer->getSuperusers(),
),
array('deny', // Deny all users
'users'=>array('*'),
),
);
}我需要你的帮助。请
请注意::我也在使用yii-user。yii-user运行良好。
发布于 2013-12-01 16:24:22
在你的控制器中,你需要命名你的动作来执行功能。
public function accessRules(){
.......
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('create','update','districts','center'),
'users'=>array('@'),
......
}例如,在上面的代码中,区域和中心是动作。
希望你能明白这一点。
发布于 2014-04-02 02:43:09
我知道这是个老问题,但你有没有补充
public function filters()
{
return array(
'accessControl',
);
}去AssignementController吗?Yii需要它将函数accessRules()用于访问控制。
发布于 2015-01-30 09:33:51
设置您的“Yii::app()->用户名->姓名”;
尝尝这个
<?php
class UserIdentity extends CUserIdentity
{
protected $_id;
const USER_INACTIVE = 3;
public function authenticate()
{
$p= Person::model()->findByUsername($this->username);
if (empty($p))
$this->errorCode = self::ERROR_USERNAME_INVALID;
elseif (!CPasswordHelper::verifyPassword($this->password, $p->password))
$this->errorCode = self::ERROR_PASSWORD_INVALID;
else
{
$this->_id = $p->id;
$this->username = $p->username;
$this->errorCode = self::ERROR_NONE;
}
return !$this->errorCode;
}
public function getId() {
return $this->_id;
}}
行"$this->username = $p->username;";
希望这能有所帮助。
https://stackoverflow.com/questions/20310116
复制相似问题