Welcome to the Cookbook

loading...

5.2.5.2 allow

If you have some actions in your controller that you don't have to authenticate against (such as a user registration action), you can add methods that the AuthComponent should ignore. The following example shows how to allow an action named 'register'.

    function beforeFilter() {
        ...
        $this->Auth->allow('register');
    }
  1. function beforeFilter() {
  2. ...
  3. $this->Auth->allow('register');
  4. }

If you wish to allow multiple actions to skip authentication, you supply them as parameters to the allow() method:

    function beforeFilter() {
        ...
        $this->Auth->allow('foo', 'bar', 'baz');
    }
  1. function beforeFilter() {
  2. ...
  3. $this->Auth->allow('foo', 'bar', 'baz');
  4. }

Shortcut: you may also allow all the actions in a controller by using '*'.

    function beforeFilter() {
        ...
        $this->Auth->allow('*');
    }
  1. function beforeFilter() {
  2. ...
  3. $this->Auth->allow('*');
  4. }

If you are using requestAction in your layout or elements you should allow those actions in order to be able to open login page properly.

The auth component assumes that your actions names follow conventions and are underscored.