Difference between
#1 and
#2 of
Simple RBAC
Revision #2 has been created by hasanavi on Apr 29, 2012, 10:16:22 PM with the memo:
grammar
« previous (#1) next (#5) »
Changes
Title
unchanged
Simple RBAC
Category
unchanged
Tutorials
Yii version
unchanged
Tags
unchanged
Simple RBAC, Role based access control, roles, Authentication, Role based menu
Content
changed
If you are the one who need
s simple Role based access control without the long RBAC process then this article is
just for you. Lets jump to the point.
On you
r user table make a column name
sd 'roles'
When you add users
under roles you can assign them
different roles like 'Admin' / 'user' / 'staff' etc etc.
On you
r User
Identity.php file write something like..
```php[...]
Now, make a Utils.php file under protected/components directory and implement a simple Role check function based on how many roles you have.
```php[...]
```
Here I just protect my AdminController.php from unauthorised accessother roles than Admin. Basically from AdminController.php file accessRules() function it checks the users Roles written in Utils.php file.
You can also use
1just one menu for all users based upon
different roles. for example
```php
<?php $this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('label'=>'Users', 'url'=>array('/manageUser/admin'), 'visible'=>Utils::isAdmin()),
array('label'=>'Ideas', 'url'=>array('/manageIdea/admin'), 'visible'=>Utils::isAdmin()),[...]