CakePHP | How to skip CakePHP authentication for some controller methods

Author - Rita

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’);

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

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