Yii framework: CPhpAuthManager error

336 views Asked by At

I try to make a RBAC with this guide I made it work without errors so far, but i got stuck now for a few hours, cause the rules in my model just wont work. I try to test the reader role with this code:

<?php if(Yii::app()->user->checkAccess('reader')): ?>
<h1> Grats u are a reader </h1>

<?php endif; ?>

So after i log in this litle message should appear but somehow it wont. And for example when i log in and try to go to my models index, so i can see the registered users it is telling me that i dont have the permission, even thought i did this:

         array('allow',  // allow all users to perform 'index' and 'view' actions
            'actions'=>array('view','index'),
            'roles'=>array('reader')

        ),

Any idea is welcome, and tell me if i have to show some more code. Ok back to thinking.

1

There are 1 answers

0
Barta Tamás On

Fixed it. Just had to give straight accessRules. Like the reader can go to index , and view page, but cant do to update , and admin, and the inverse of this for the admin role.