问题
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!
回答1:
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
回答2:
Maybe you have to use this method for cakephp3.x , in your controllers:
public function initialize()
{
$this->Auth->allow('youraction'); // this action will plublic. Not under auth control.
}
Hope this link can help you: https://book.cakephp.org/3.0/en/controllers.html#the-app-controller
来源:https://stackoverflow.com/questions/47183492/cakedc-users-how-to-work-with-permissions