Set accessRules to use Yii::app()->admin not Yii::app()->user

Hi!

problem is i dont know how to tell Yii to understand in AdminController that i want to check roles for Yii::app()->admin, not user

I have two CWebUsers defined in config/main.php


		'user'=>array(

		    // enable cookie-based authentication

		    'allowAutoLogin'=>true,

		    'loginUrl'=>array('site/index'),

		),

		'admin'=>array(             // Webuser for the admin area (admin)

		    'class'=>'CWebUser',

		    'allowAutoLogin'=>false,

		    'loginUrl'=>array('admin/login'),

		    'stateKeyPrefix'=>'admin_',

		),



And if i use


'roles'=>array('createPost')

i think yii trying to search in Yii::app()->user permissions.

Take a look at Authentication / Authorization.

You need to an authorization manager for using ‘roles’.

I have all set-up and if i would use role sin UserController, it would work.

Only problem is that i have

  • two separated tables user, admin

  • two separated controllers UserController, AdminController

and if i use roles, this would trigger Yii::app()->user permission checking (not Yii::app()->admin).

If i misunderstood your solution, please give me one more hint :)

Sorry I forgot the link - see rbac: topics.auth

I don’t know what you mean by


'roles'=>array('createPost')