1

我已经安装了 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'),
        ),

    ),

但是当我输入 urlhttp://localhost/rightsTest/index.php/rights然后它说

Error 403
There must be at least one superuser!

我尝试了很多东西,但找不到答案。谢谢你的帮助。

4

4 回答 4

1

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

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

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

  4. 保存 main.php

并尝试重新加载权限。问题将得到解决。:)

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

于 2014-02-13T05:35:27.900 回答
1

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

于 2013-11-14T11:14:57.393 回答
1

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

于 2013-11-14T07:37:11.630 回答
0

我有同样的问题,我在 RAuthorizer 中添加了我的超级用户名。在权限/组件/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;

它有效。

于 2015-04-29T06:17:18.117 回答