Changes
Title
unchanged
Simple access control
Category
unchanged
Tutorials
Yii version
unchanged
Tags
unchanged
simple, access, control, accessControl, accessRules, allow, deny, user, users
Content
changed
For those who feel, the Controller->accessRules() or RBAC (Role-Based Access Control) is too complicated or
lengthily to codedoesn't want the username(s) to be hard-coded in accessRules(), here is a very simple, easy-to-implement solution.
Considerations
--------------
As usual, you will have a table, holding the user's data, such as: username, password, email, real_name, etc. To store the user rights, you need an additional field, named **admin_level**. This will be an unsigned tinyint, and will hold the user's rights to do things around the site.
You will define the admin levels, according to your needs. Now, for this example, let's define 4 levels:[...]