cakephpcakephp-3.0cakedc

CakeDc/users how to work with permissions?


I installed CakeDC/users run migration, created the super user, copied the users.php to config/ directory.

And now in my website all pages are redirecting to login page. And i can't change this thing, cause i not well understand how permissions work.

My needs are to allow all pages on site, and block access only for one page with personal data for the user loggedin.

Any help, suggest readings, examples are welcome, BIG thanks!


Solution

  • You will need to allow all actions in the beforeFilter of your AppController.

    public function beforeFilter(Event $event)
    {
        $this->Auth->allow();
    }
    

    See AuthComponent::allow

    You will then need to deny the action that requires authentication in the beforeFilter of the controller that has that action.

    public function beforeFilter(Event $event)
    {
        // Where `loggedInAction` is the name of the
        // action that requires authentication 
        $this->Auth->deny('loggedInAction');
    }
    

    See AuthComponent::deny