Rahul Kumar, on 06 February 2011 - 03:20 AM, said:
Hello Folks,
Please help me out. I am stuck in Chapter 8.
I executed rbac command successfully for Authorization hierarchy.
When I click on 'Add user to Project'. It says
Error 403
You are not authorized to per-form this action.
I don't know what is happening.
Help me out.
Two things need to check:
1- Make sure that your accessRules() has allowed adduser action to & (signed in), and IT IS ON TOP OF ALL OTHER RULES OR AT LEAST JUST PUT IT ON TOP OF THE DENY ALL RULE. Don't get me wrong, it is not required to be always on top of all other rules, but the default last rule in the book is to deny *, so if you put your adduser rule below it, you won't have a chance to access action adduser.
public function accessRules()
{
return array(
array('allow',
'actions' => array('index', 'view', 'adduser'),
'users' => array('@')
),
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('create','update'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete' actions
'actions'=>array('admin','delete'),
'users'=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
2- If you have correctly updated your accessRules(), you need to check to make sure your account you're using to sign in, is the user who has access to the operation 'create new user'. This operation is obviously in task user management, and assigned to role owner. So the user must be the owner of the project you're currently browse. Go selecting from your database to make sure on that.
In my case, I don't know what going on, I stuck at this point (hope you don't), while my database shows Test_User_One is the owner of the project, my accessRules is correctly set, but this god damn Yii::app()->checkAccess() always returns FALSE.
Your printed screen looks like you put this link: Add User To Project in wrong place, so you might also look into this file ....\trackstar\protected\views\project\view.php and add it as the vertical menu item as below:
......
......
$this->menu=array(
array('label'=>'List Project', 'url'=>array('index')),
array('label'=>'Create Project', 'url'=>array('create')),
array('label'=>'Update Project', 'url'=>array('update', 'id'=>$model->id)),
array('label'=>'Delete Project', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
array('label'=>'Manage Project', 'url'=>array('admin')),
array('label'=>'Create Issue', 'url'=>array('issue/create', 'pid'=>$model->id)),
array('label'=>'Add User To Project','url'=>array('adduser','id'=>$model->id)),
);
......
......