overwrite user within module

Hi

Im going to setup rights module inside another module(admin).

In my /protected/config/main.php defined as


'user'=>array(

	// enable cookie-based authentication

	'allowAutoLogin'=>true,

	'class'=>'CWebUser',

),

In my modules/admin/AdminModule.php, inside init method defined as


$this->setComponents(array(

	'errorHandler' => array(

		'errorAction' => 'admin/default/error'),

		

	'user' => array(

		'class' => 'RWebUser',             

		'loginUrl' => Yii::app()->createUrl('admin/default/login'),

	),

	

	'authManager'=>array('class'=>'RDbAuthManager') 

));

within admin module I check permission as


Yii::app()->user->checkAccessList(array('Rights.Assignment.*'));

But Im getting error "CWebUser and its behaviors do not have a method or closure named "checkAccessList". Seems its not loaded the RWebUser class.Does anyone can help me to solve it?

Thanks

Aruna

u cant have 2 user component in an application(one will override the other). i think you should define the behavior inside the CWebuser. or simply rename the user component name for rwebuser to something like Ruser.




$this->setComponents(array(

        'errorHandler' => array(

                'errorAction' => 'admin/default/error'),

                

        'Ruser' => array(

                'class' => 'RWebUser',             

                'loginUrl' => Yii::app()->createUrl('admin/default/login'),

        ),

        

        'authManager'=>array('class'=>'RDbAuthManager') 

));



Hi thanks for the response, I have tried with your suggestion but got the error "Property "CWebApplication.Ruser" is not defined.". I accessed it as follows on layout/main.php


Yii::app()->Ruser->checkAccess('Rights.Assignment.*');

why not put the Ruser inside the component array of the main config file or just calling it directly.




       //assuming the component class is inside any of the autoloaded dir

           RUser::accessCheck(Yii::app()->user->id); 

    

if you are sure the RUser class is meant for a specific module then the last option is better.

Yes RUser(RWebUser) class belongs to the "rights" module. I just want to setup it inside another module.

Main app

|

|->modules

     |


     |->admin


          |


          |-> Modules


                 |


                 |->rights

main app no need RBAC but admin module required RBAC so I used "rights".As you said I have configured RUser component in protected/config/main.php and works fine.But the problem is inside rights module it uses as "Yii::app()->user" so I have to change them as Yii::app()->RUuser, without doing that can I switch user object as needed one for normal users and other for administrators.Appreciate your help

Thanks

Aruna

i think you should additionally create a custom component class for user that will have all the custom method for the RUser inside. if you already have that in place just add some of the methods to that class.