Rbac - How To Check/change Role Of Users

Hey there,

I just started using yii in my first little project. Yesterday I started experimenting with the RBAC-System of yii. I know there are Extensions for that but I want to understand it myself so I decided to use yii only.

I only created 2 roles "User" and "Admin" and assigned them to 2 Users





In my Controller I created the following accessrules to see if it works

return array(


            	'actions' => array('index', 'add'),

            	'roles' => array('admin'),



            	'actions' => array(),




It works. My Admin can access both actions and my normal User cannot. BUT, how can I see the actual role I assigned to the User? Or how can I get all Users or all Admins at once?

I’m planning to write an Admin Panel where I can change the userroles but I don’t know how I can get the actual role a user has.

I know I could save the role in my user Table in an additional column but this could lead to inconsitency of my DB. And the roles are already stored somwhere so I should be able to access this information ;)

Any suggestions?

There are several implementations for this.

I use RBAM Manager (http://www.yiiframework.com/forum/index.php/topic/14235-rbam-role-based-access-control-manager/ ) - you may want to use another one.

That’s exactly what I NOT wanted. I want to understand the RBAC yii provides so I don’t have to rely on someone else’s work. I don’t like the idea that perhaps the extension gets abandoned or doesn’t work with higher yii-versions.