首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Yii Rights ::Error 403您无权执行此操作

Yii Rights ::Error 403您无权执行此操作
EN

Stack Overflow用户
提问于 2013-12-01 16:09:40
回答 3查看 3K关注 0票数 1

我是新来的。根据文档,我将yii-rights安装在protected/modules/rights中。但不能正确使用。有一些我找不到的东西。localhost/index.php/right页面工作正常。但当我按下“权限”、“角色”、“任务”、“操作”时。它显示了

“错误403您无权执行此操作。”

下面是我的主要配置::

代码语言:javascript
复制
'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

代码语言:javascript
复制
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运行良好。

EN

回答 3

Stack Overflow用户

发布于 2013-12-01 16:24:22

在你的控制器中,你需要命名你的动作来执行功能。

代码语言:javascript
复制
  public function accessRules(){
    .......   
    array('allow', // allow authenticated user to perform 'create' and 'update' actions
                    'actions'=>array('create','update','districts','center'),
                    'users'=>array('@'),
    ......
    }

例如,在上面的代码中,区域和中心是动作。

希望你能明白这一点。

票数 2
EN

Stack Overflow用户

发布于 2014-04-02 02:43:09

我知道这是个老问题,但你有没有补充

代码语言:javascript
复制
public function filters()
{
    return array(
        'accessControl',
    );
}

去AssignementController吗?Yii需要它将函数accessRules()用于访问控制。

票数 0
EN

Stack Overflow用户

发布于 2015-01-30 09:33:51

设置您的“Yii::app()->用户名->姓名”;

尝尝这个

代码语言:javascript
复制
<?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;";

希望这能有所帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20310116

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档