AuthManager multiple roles

Hello everyone,

I´ve been developing an application which has a permisssions section in which administrators can assign multiple roles to users. Based on these roles, I have a menu which must show only items for users who have a certain role assigned. For example:

User1 has role1 and role2

Menu: ITEM 1 (visible ONLY for role 1), ITEM 2 (visible only for role 2).

So, when User1 logs in, automatically authmanager retrieves role1 and role2 and assign it to User1, which makes the menu to show both ITEM1 and ITEM2.

What I want is:

Step 1) User1 logs in (no roles assigned so far)

Step 2) System identifies roles available for this user and asks him which one he wants to use

Step 3) Based on the single role User1 chose, either ITEM 1 or ITEM 2 should be displayed.

How can I achieve that?

I was trying to find the file in which the roles are assigned right after the UserIdentity.php is called, but no results so far =/

Thanks in advance

use RBAC (http://www.yiiframework.com/doc/guide/1.1/en/topics.auth#role-based-access-control) or any of "RBAC" extensions available in repository… Exensions have advantage of providing UI to manage users and roles to basic RBAC.

I´m actually using one extension in particular - Rights - but I´m still facing the problem. Probably because these extensions are all based on yii RBAC and by default (as far as I know), Yii loads all user´s roles at once when he logs in. I wish I could make this ‘loading’ lazy so I could choose which role to log in to.

Redguy, in the end of the text you sent me it says:

"Once we have established this hierarchy, the authManager component (e.g. CPhpAuthManager, CDbAuthManager) will load the authorization items automatically. "

I guess that´s where I want to modify the settings.

Any other suggestions?

Well according to me its not related to any extension. You have created your Own authorization system.Which is great.The thing which you are trying to do here is a logical approach.

So, what you can do here is to force user to select a role.After Login Just redirect user to any other page where give a possibility to user to choose a role.Then according to selected Role.Just assign a selected role with setState() method.