RBAC role assigned at login


I’m brand new to Yii so please be gentle with me!

I’m looking at RBAC for setting up different permissions for different types of users. My intention, is to store the “role” as a field in the “users” table.

I had hoped I would be able to use the "assign" method, to assign the role to the user at login time, however I find that it is inserted into the database, and therefore on the second login creates problems.

I could issue a bunch of revoke commands I guess prior to assigning the role (there will be 5 roles), but this doesn’t seem logical. I looked for an update method, but doesn’t seem to be one.

Any suggestions please ?



Hi Windsor,

Thanks for your detailed reply.

I understand what your saying, and I had created the 3 tables you mentioned, from the schema file.

From what I have looked at, I understood the following was required in order to assign a user to a particular role…


Now, it’s possible the users role may change, and rather than update this table manually, I thought it would be useful to do the check at login, and update if necessary.

Maybe my logic is wrong ?

Anyway - have purchased the 2 yii books to take a look at in the meantime :)