CakePHP | How to skip CakePHP authentication for some controller methods

|
| By Webner

Description: By default, CakePHP authentication is applied to all application controllers. So it does not allow users to perform any of the action without login.

Solution: Each controller has a beforeFilter method which runs when some action is called from controller. Add below lines to your method:

Public function beforeFilter(Event $e)
{
  parent:beforeFilter($e);
  $this->Auth->allow(‘name of the function here‘);
}

Add the name of your functions to which you want to allow access without login. If it is more than one, create an array in that case:

$this->Auth->allow([‘method1 ‘ ,’method2’ ,’method3’);

Leave a Reply

Your email address will not be published. Required fields are marked *