How to create access restriction for an action on yii2.0

0

I need the client user to just view the posts records of my system. I would like to know how to restrict on-screen actions to the client user, so that this user can only view the records, and not appear for him the change, delete and register buttons. The admin user who will have full access to the system.

    
asked by anonymous 28.03.2016 / 12:43

1 answer

1

Yii2 has support for Access Control. They are:

They are best explained in documentation . But in summary:

AccessControl , you will use a project that:

  • does not have many controllers / actions;
  • There will not be many permissions changes for users and * roles are well defined;
  • will not be created / edited very often.

This is because you will have to define in each controller which actions each role * can perform.

The DbManager class (which uses the RBAC concept) creates the tables where all this information will be stored of what permission or role * each user has.

If this idea of going into each controler and making changes is not feasible for your project, I'd recommend taking a look at in this library .

*: name given to the role / profession / position you assign to users, eg administrator, editor, etc.     

12.07.2016 / 17:45