Php Yii用户权限扩展

Php Yii用户权限扩展,php,yii,Php,Yii,我已经安装了yii权限扩展,这是我安装后的代码,数据库表是在安装后创建的 'modules'=>array( // uncomment the following to enable the Gii tool 'rights'=>array( 'superuserName'=>'Admin', // Name of the role with super user privileges.

我已经安装了yii权限扩展,这是我安装后的代码,数据库表是在安装后创建的

'modules'=>array(
        // uncomment the following to enable the Gii tool

            '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.    '
                          // Key to use for setting success flash messages.  
                            'flashErrorKey'=>'RightsError',  
                            / Key to use for setting error flash messages.    
                          //  'install'=>true,    // Whether to install rights.    
                            '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,
                    ),


        'gii'=>array(
            'class'=>'system.gii.GiiModule',
            'password'=>'1234',
            // If removed, Gii defaults to localhost only. Edit carefully to taste.
            'ipFilters'=>array('127.0.0.1','::1'),
        ),

    ),
但是当我键入url
http://localhost/rightsTest/index.php/rights
然后它说

Error 403
There must be at least one superuser!

我试过很多东西,但都找不到答案。谢谢您的帮助。

您是否有id、用户名文件的用户表,并且必须检查该表中是否至少有一条记录。因为权限选择用户表中的第一条记录作为管理员角色。

创建新的管理员用户。数据库中有一个“用户”表,它具有权限模块,使用您选择的“用户名”、“密码”输入您的管理员用户,并且不要忘记将“超级用户”和“状态”字段值设置为1

您尚未在配置文件中指定超级用户

  • 在yii安装中打开protected->config->main.php文件
  • 查找以下与权限配置相关的行

        'rights'=>array( 
              'install'=>false, // Enables the installer. 
              'userNameColumn'=>'user_name',
              'userClass'=>'Users',
              'superuserName'=>'your_superuser_username'
        ),
    
  • 输入您的超级用户用户名作为“超级用户名”的值

  • 保存main.php
  • 并尝试重新加载权限。问题将得到解决。:)


    注意:确保在此处正确指定了用户表的用户类和用户名列。否则,您可能会面临另一个问题。快乐编码!谢谢。

    我也有同样的问题,我在RAuthorizer中添加了我的超级用户名。在权限/组件/授权程序中

    $superusers = array('beautiful'); // Beautiful is my superadmin username
    foreach( $users as $user )
    $superusers[] = $user->name;
    
        if( $superusers===array() )
        throw new CHttpException(403, Rights::t('core', 'There must be at least one superuser!'));
        return $superusers;
    

    它可以工作。

    您是否检查了指定为超级用户的帐户是否确实存在?也许在你的数据库中它被称为“admin”,而不是“admin”。我没听清楚,你说的是哪个数据库表?我认为是这个扩展在数据库中创建了4个表。Authassignment、authitem、authitemchild、权限。我可以问一下你说的是哪个表吗?嗯,你在某处有一个用户表——毕竟用户数据必须从某处提取。这就是我所说的信息来源。是的,我有一个用户表,我已经检查了它,出现了相同的错误403。只需补充说明,权限的创建者创建了另一个应用程序来处理权限,该应用程序比权限更少的错误和更灵活: