Auth Component redirects automatically in cakePHP
After adding Auth component while accessing the home page it redirects to login page
ie., let www.domain.com is my url. After adding the auth component when i try to access www.domain.com it redirects to www.domain.com/logins/login.how can i avoid this initial redirection??
i already given a route as below
Router::connect('/', array(
'controller' => 'pages', 'action' => 'display', 'home'
));
but开发者_JAVA技巧 no use
thankz in advanceIn your pages_controller.php (if you don't already have one in app/controllers
, copy the one from cake/libs/controller
:
function beforeFilter()
{
parent::beforeFilter();
$this->Auth->allow('*');
}
In AppController::beforeFilter() add the following:
$this->Auth->allowedActions = array('display');
UPDATE: allowedActions
are controller actions for which user validation is not required.
http://api.cakephp.org/2.4/source-class-AuthComponent.html#228-234
You could also just add this code to your users
controller to stop it from automatically redirecting, but like everyone else said, you should also allow display
.
function beforeFilter() {
...
$this->Auth->autoRedirect = false;
}
http://book.cakephp.org/view/395/autoRedirect
精彩评论