xiidea / ezRbac

A simple yet easy to implement Role Based Access Control Library for popular PHP framework Codeigniter
http://xiidea.github.io/ezRbac/
86 stars 39 forks source link

Example #31

Open mflash123 opened 6 years ago

mflash123 commented 6 years ago

Please, add any simple example. I made 2 actions and both is view. However both can write to db. Need examples

ronisaha commented 6 years ago

@mflash123 This library does not prevent db writing. Can you provide example repository so i can check what you are trying to do.

Happy coding!

mflash123 commented 6 years ago

Sorry, I dont have examples here. Thanks for answering.

    public function index()
    {
        $this->load->view('welcome_message');
    }
    public function test()
    {
                //db writing but it shoudnt because of rbac only view option
        $this->Common_m->saveAnything( 'test' ,array("id"=>1) );
    }

    public function access_map(){
        return array(
            'index'=>'view',
            'test'=>'view'
        );
    }

So, if rbac doesnt prevent from DB writting, what access_map means? Rbac means only flags in DB for each users and controllers? I mean that only notification/flags and that is not any prevents?

ronisaha commented 6 years ago

The access code spinet means any user with group that have view permission can access your index and test function. If you want to prevent a use to access the test function but give access to index function You can give the user view permission only and set the access_map like:

   public function access_map(){
        return array(
            'index'=>'view',
            'test'=>'write'
   );

That means test can access the user who has the write permission.

Happy coding