Specifying Access Rules Specific Error Message In Controller

Hi,

I am currently using yii 1.1.10 version in which I am trying to specify rules specific error message by defining message in accessRules function as specified below:

public function accessRules()

{


	return array(


	array('allow',  // allow all users to perform 'index' and 'view' actions


			'actions'=>array('xxx','yyy'),


			'users'=>array('*'),


	),


	array('allow',  // allow all users to perform 'index' and 'view' actions


                            'message'=>'You must be logged in as Member to perform this action.',


                            'actions'=>array('zzz','aaa',),


                            'expression'=>'AuthenticationHelper::isSessionUserAdmin()',               


	),


			array('deny',  // deny all users


			'users'=>array('*'),


                            'message' => "This is a generic message.",


	),


	);


}

However in case expression fails, I am able to view only message that has been specified against deny rule which is "This is a generic message.", even when second evaluation fails. Any points to achieve desired behavior is highly appreciated.

Thanks

Tarun

Hello tarun_kumar!

I think you should define the ‘users’ parameter in accessRules() on the second array, something like:




...

array('allow',

   'actions' => array('zzz','aaa',),

   'users' => array('@'),

   'message' => 'You must be logged in as Member to perform this action.',

   'expression' => 'AuthenticationHelper::isSessionUserAdmin()', 

),

...