I am now trying to develop a website under the Yii framework and Role-Based Access Control(RBAC) is needed in the program. I read from the guide that filter can be used for RBAC, but I wonder what should I do if the administrators and users are store in two tables? Namely if there are two tables in the database, one for admins and on for users, how should I implemented access control? Thank you.
Share
I think this is not possible out of the box. When you check the db schema of authassignment, you will see that it has a userid field, which relates to your users table. If you have two different tables, you would need another unique identifier in the auth table. Is it absolutely necessary that you have two different tables for your users? Actually, RBAC is very useful for separating concerns. So you have one user table, but you can assign your users different roles such as “admin”, “editor” etc. If you have two different user tables, what do you do if a user becomes an admin? This is complexity that you shouldn’t have to handle. If you absolutely have to, you will have to extend the RBAC functionality to make it possible to refer tp different tables.