I am using the rights extension of Yii and get this error:
There must be at least one superuser!
I don't know what this superuser
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.
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
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.
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
FWIW (since it's been so long), you have to grant one of your users the superuser role.
That role name is denoted in the superuserName
property in the config file, as shown in your post. This can be done directly via SQL, by updating the authAssignment
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).
The naming is a bit misleading, I stumbled upon that problem also.
superuserName
should be named superuserRole
, meaning that all users which are assigned to the role specified there are super-users.
Please note that Yii::app()->user->checkAccess('whatever')
will always return true
for super-users.
See also RAuthorizer.php:
/**
* @property string the name of the superuser role.
*/
public $superuserName;
and RWebUser.php.
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
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.