I have tried to perform
$this->Auth->allow() in beforeFilter() but, I need to add entire controller as an exception, i.e. it needs to be public and does not require user to be signed in.
Just a short-cut way to perform $this->Auth->allow( every-function-in-this-controller )
Answers?
Edit:
I have this:
<?php
App::uses('AppController','Controller');
class AllzonesController extends AppController {
public function __beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('index');
}
public function index() {
$this->layout = 'main';
$this->set('Hello',"Hello world");
}
}
It is transferring Auth-login()
What you proposed is the appropiate way of what you want to do
public function beforeFilter() {
$this->Auth->allow();
}
Reading the API docs
Takes a list of actions in the current controller for which authentication is not required, or no parameters to allow all actions.
So the function with no parameters should allow a normal user (not logged in) to access every action of that controller.
EDIT :
Sorry, missed the version reference in your tag. In here it says
$this->Auth->allow('*');
is the appropiate way for Cake 2.0 (and previous versions, as noted by @mark)
For versions beyond CakePHP 2.1
$this->Auth->allow()
instead of $this->Auth->allow('*')
and
To my other question __beforeFiter is not a magic function!
<?php
App::uses('AppController','Controller');
class AllzonesController extends AppController {
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('index');
}
public function index() {
$this->layout = 'main';
$this->set('Hello',"Hello world");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With