简体   繁体   中英

Yii framework: CPhpAuthManager error

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM