php - What does superuser mean in the rights-extension of Yii?

270

I am using the rights extension of Yii and get this error:

There must be at least one superuser!

I don't know what thissuperuser means since I am using the default authentication with user admin and demo. After reading the documentation of rights extension, I tried to configure rights with:

'rights'=>array(
    'superuserName'=>'admin',
    'install'=>true
),

But it doesn't work, I have searched the internet but got no result.

927

Answer

Solution:

you need to connect the user table with a table AuthAssignment, whose name has been declared in the array setting

'modules'=>array(
'rights'=>array(
    'superuserName'=>'admin',
     ),
 ),

then, you have to change the table AuthAssignment userid field that refer to field id on table user

628

Answer

Solution:

If you have installed user and rights like here, Just run this in your database:

INSERT INTO `AuthAssignment` (`itemname`, `userid`, `bizrule`, `data`) VALUES ('Admin', '1', NULL, 'N');
INSERT INTO `AuthItem` (`name`, `type`, `description`, `bizrule`, `data`) VALUES ('Admin', 0, 'Admin', NULL, 'N;'); 

Note: In the tutorial all table names of rights module are in lower case.

791

Answer

Solution:

The naming is a bit misleading, I stumbled upon that problem also.

superuserName should be namedsuperuserRole, meaning that all users which are assigned to the role specified there are super-users.

Please note thatYii::app()->user->checkAccess('whatever') will alwaysreturn true for super-users.

See also RAuthorizer.php:

/**
* @property string the name of the superuser role.
*/
public $superuserName;

and RWebUser.php.

125

Answer

Solution:

FWIW (since it's been so long), you have to grant one of your users the superuser role.

That role name is denoted in thesuperuserName property in the config file, as shown in your post. This can be done directly via SQL, by updating theauthAssignment table (its name may be different in your case, it is configurable).

INSERT INTO `authassignment` (`itemname`, `userid`, `bizrule`, `data`) VALUES ('admin', '1', NULL, 'N;');

Then, log in as the appropriate user (the one corresponding to id #1, in this particular case).

904

Answer

Solution:

there's a small hack, line you have to comment out for it to work...

check official extension page comments

EDIT: I didn't want to post a link to my own blog because it looks like self-promoting but it's a very comprehensive solution to your problem I think : installing yii-rights extension

592

Answer

Solution:

i think you have to use mysql database and table user not default authentication -it is just a example of authentication-. after you import user table you should add a user with username "admin" -if u have "admin" in superuserName config- in user table.

582

Answer

Solution:

I managed to install it by following a post on the yii-forums - here is a permalink to my post: http://www.yiiframework.com/forum/index.php/topic/10556-extension-rights/page__view__findpost__p__229721

People are also looking for solutions to the problem: session - php $_SESSION TWIG + Mini2

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.