Yii Rights Extension – Error 403. There must be at least one superuser! – SOLVED

In my previous post I demonstrated how to install Yii Rights extension easily and quickly. We commented out the code for checking superuser given below.

Now to address this issue simply edit file /modules/rights/components/RAuthorizer.php and comment out the lines near line no 304 and 305.

    //if( $superusers===array() )
         //  throw new CHttpException(403, Rights::t('core', 'There must be at least one superuser!'));

However it will make any user to use the Rights interface, even the not logged in user can use this module and change permission which is not good for a production environment.

In order to enable user permission for using the Rights module I could not find any solution on searching the internet. Then I come up with a manual but very easy procedure. I entered a two entries in the database manually. .

1. There must be a record in the table AuthItem table with the name (e.g. admin ). If there is no such record add it manually.
2. Now add a record to Rights table with the itemname similar in step 1. (e.g. admin). The other two columns type and weight does not really matter here so put any integer value (e.g. 0).
3. Now uncomment the code above for if( $superusers===array() ).

Now only the user admin will be able to use Rights module and grant or revoke permissions because in Rights Extension now admin is the superuser.

Cheers 🙂

Leave a Comment

Your email address will not be published. Required fields are marked *