Reputation: 721
I want that my home (View/Pages/home.ctp) to become a public view, cause everytime I try to access, redirects me to /users/login.. AppController.php:
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array('controller' => 'users', 'action' => 'areaRestrita'),
'logoutRedirect' => array('controller' => 'users', 'action' => 'logout'),
'authError' => 'Você deve fazer login para ter acesso a essa área!',
'loginError'=> 'Combinação de usuário e senha errada!'
)
);
BeforeFilter:
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow( 'index' );
}
What should I do? I tried to put a beforeFilter at pagesController.php to allow('display') but doesn't works.
Upvotes: 0
Views: 162
Reputation: 8100
You allow actions not views using Auth. The default Pages controller of CakePHP uses the same display()
action to render all static views. So if you want to allow just the homepage either make a separate action for it and route "/" to that action, or in beforeFilter()
use $this->request->params
to check if the request is for homepage and use $this->Auth->allow()
.
Upvotes: 1