Wednesday, January 5, 2022

[FIXED] CakePHP page restriction interface

Issue

I have multiple user access groups and I am currently using this code to restrict user access groups from certain pages.

public function add()
    {
        if($this->request->session()->read('Auth.User.access_id') != '1 ')
            {
                //$this->request->session()->setFlash('You are not authorized to visit this page','flash',array('alert'=>'info'));
                $this->redirect('/dashboard');
            }

I want to be able to create an opencart type interface for allowing access for different pages for each user access groups.

Opencart Image Example

So I want to create check boxes to modify access so that admins can easily create new user access groups and modify existing ones without touching the code. The only way I can think to do this is for the check boxes to modify the code for every controller. Would someone suggest a way to do this?


Solution

Best way to achieve that is the ACL plugin.

https://github.com/cakephp/acl

This is how I use it (is in italian) 1]



Answered By - David A.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.