Trouble Whit Checkaccess Method


I’m learning in theese days for a first time Yii Framework and I have a trouble in setting authorization.

My goal is to personalize menu based on the user’s role.

In controller file I put this simple code:

protected function loadAuth()



		$auth->createOperation('manageUtenti','gestisci gli utenti');







	public function init()




and I notice that this execution insert in my database table authorization the correct records in AuthItem and AuthItemChild tables.

During the authentication I set the user roles in this way:

$this->setState('roles', $record->VANUT_Roles);

in the authenticate() method:

public function authenticate()





		else if($record->VANUT_Password!==crypt($this->password,$record->VANUT_Password))





			$this->setState('roles', $record->VANUT_Roles);



		return !$this->errorCode;


In my menu file I put this code:


                    'htmlOptions'=>array('class'=>'pull-right nav'),





                        array('label'=>'Dashboard', 'url'=>array('/site/index'),'visible'=>Yii::app()->user->checkAccess('manageUtenti')), ....

But the command Yii::app()->user->checkAccess(‘manageUtenti’) return everytime FALSE. Also when the user logged have user role.

What I mistake?

Thank in advance for your help!

Have a nice day,


Well looks like you have created an role but you have not assigned it to the user you have to assign that role to user take a look at the guides

Thank you very much now it’s work!