Jump to content
Larry Ullman's Book Forums

Using Role Property In Accessrules


Recommended Posts

I've been following this tutorial, which is great btw, and have one question.



I can access the role property like this, anywhere in my application code:



but, what I'd really like to do is use the default controller authorization in my UserController:

 * Specifies the access control rules.
 * This method is used by the 'accessControl' filter.
 * @return array access control rules
public function accessRules()
 return array(
  array('allow',  // allow all users to perform 'index' and 'view' actions
					    // Fails
					    // Also Fails
						    'expression'=>'(isset(Yii::app()->user->role) && (Yii::app()->user->role==ModelConstantsRole::ADMIN))',
  array('deny',  // deny all users


It appears that the class that actually validates the rules defined in accessRules doesn't actually know anything about my role that I've assigned it.

CAccessControlFilter (for those of you who don't want to search for it for 40 minutes XD).


Any ideas on how I can make use of the accessRules method when I combine it with Larry's approach?



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...