Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP Auth $this->Auth->allow('display')

I have a problem showing static pages to non-authenticated users in my app.

I'm using cake 2.1 and my AppController.php is like this:

App::uses('Controller','Controller');

class AppController extends Controller {
    public $components = array(
        'Session',
        'Auth' => array(
            'loginRedirect' => array('controller' => 'users', 'action' => 'index'),
            'logoutRedirect' => array('controller' => 'users', 'action' => 'login')
        )
    );

    public function beforeFilter() {
        $this->Auth->allow('display');
    }
}

Please help me. Thanks!

like image 563
mirko.cek Avatar asked Apr 29 '26 15:04

mirko.cek


2 Answers

You are close, but the display action is not part of the AppController. It belongs to the PagesControllerinstead.

Try adding this logic to the PagesController located under app/Controllers/PagesController.php. That should do the trick.

like image 86
Oldskool Avatar answered May 01 '26 03:05

Oldskool


You need to do this in PagesController

public function beforeFilter() {
        parent::beforeFilter();
        $this->Auth->allow('display');
}

At least it worked for me. Hope it helps someone else.

like image 31
aurelioth Avatar answered May 01 '26 03:05

aurelioth