Difference between #4 and #3 of Troubleshooting Rights Extension

unchanged
Title
Troubleshooting Rights Extension
unchanged
Category
Tips
unchanged
Tags
extension, Rights, RBAC
changed
Content
[Rights](http://www.yiiframework.com/extension/rights/ "Rights
Extension") is one of user interface for Yii's Role Base Access Control
extension. It is one of most downloaded extensions in Yii's Web. 

Sometime developers might encounter errors or incomprehensive messages from
Rights while implementing it. While there is a [thread dedicated to solve the
Rights](http://www.yiiframework.com/forum/index.php?/topic/10556-extension-rights/page__view__findpost__p__51869
"Rights thread") problems, but because it already grown to big, I
decide to collect common problems with their solutions into one wiki so it will
be easier for everyone to check.

Things Need to Check First
--------------------
- UserIdentity class has been override to return user id instead username.
- Make sure you have given CREATE TABLE access to the database user that are
going to connect the Web App with the database. Rights needs to create table on
first install.
- Make sure you have signed in as superuser or admin before running Rights
instalation.
- You need a model named **User**. If you have a user table but with another
name, change the Rights configuration


~~~
[php]
'rights'=>array(
    'userClass' => 'AnotherName',
),
~~~


- The user table MUST NOT contain field named "name" or it will
conflict with Rights
- If you inherit CWebUser, make sure the class doesn't have a method named
"getName()"


Troubleshoot
------------
**Problem**

Need to change the table name for the sake of consistency

**Solutions**

Add the code to 'authManager' in the Yii configuration files:



~~~
[php]
'authManager' => array(
    'class' => 'RDbAuthManager',
    'assignmentTable' => 'authassignment',
    'itemTable' => 'authitem',
    'itemChildTable' => 'authitemchild',
    'rightsTable' => 'rights',
),
~~~


<hr/>

**Problem**

Got message:
Filter "rights" is invalid. Controller "XyzController" does
not have the filter method "filterrights"."

**Solution**

You must extend the controller class from RController. The easiest way is change
the code at /protected/components/Controller.php 


~~~
[php]
class Controller extends RController
~~~


<hr/>


**Problem** 

Get "PropertyGot message:
"Property "CWebApplication.rights" is not
defined." message.

**Solution**

It seems you have forgot to include "rights" in the Yii's module
configuration. Please consult to documentation.


<hr/>

**Problem**

The Guest seems like not workingworking.

**Solution**

Add following setting to the Yii configuration file:


~~~
[php]
'authManager' => array(
    'class'=>'RDbAuthManager',
    'defaultRoles'=>array('Guest'),
),

~~~

<hr/>