I’m new too Yii and wanted to start pretty straightforward. I put the code for initializing the roles into an InitController. Then I initialized those roles and put the code for access checking into every action (
if(Yii::app()->user->checkAccess(‘deleteUser’)) …
). This all works pretty good, but I now want to allow users to edit their own account. So I added this rule:
$bizRule='return Yii::app()->user->id==$params["user"]->username;';
$task=$auth->createTask('updateOwnUser','update a your own account',$bizRule);
$task->addChild('updateUser');
but it just doesn't work! The values seem to match (i printed them out) but checkAccess returns false. Is it right to add updateUser as child? I've seen that in the documentation.
You only need to call Yii::app()->user->checkAccess('updateUser').
The task 'updateOwnUser' will automatically be checked first (with bizRule). If the bizRule succeeds, it will continue to check the child operation 'updateUser'.
The task 'updateOwnUser' will automatically be checked first (with bizRule). If the bizRule succeeds, it will continue to check the child operation 'updateUser'.
To members only updateOwnUser is allowed, and not updateUser so why does he check for updateUser too?
Whenever I try, Yii::app()->user->checkAccess(‘TenantUser’, array(‘tenant_id’=> $tenant_id), even if the tenant_id’s match it return false. I can’t figure out what seems to be going wrong.