Hello,
I am trying setup some roles for my blog and can't seem to grasp the idea for rbac. I've read all available posts but none was of any significant help. So I have protected/config/auth.php file with the following code:
class Auth extends CPhpAuthManager { public function init() { $auth=Yii::app()->authManager; $auth->createOperation('readPost', 'Read a post'); $role=$auth->createRole('reader'); $role->addChild('readPost'); } }
Basically I am trying to create a reader role and use it later in accessControl function of my Post/Comment controllers.
In my protected/config/main.php I have:
'authManager'=>array( 'class'=>'CPhpAuthManager', ),
In my PostController I have:
public function accessRules() { return array( array('allow', // allow authenticated users to perform any action] 'actions'=>array('view'), 'roles'=>array('reader'), ), }
I thought this should be enough to hide the posts in the blog but instead I ran into the following error:
PHP Error Description Invalid argument supplied for foreach() Source File C:\xampp\htdocs\framework\web\auth\CPhpAuthManager.php(449)
What am I doing wrong? Any help is appreciated as I am stuck. There should probably be something wrong with auth.php file but I don't know what.
cheers,
b