views:

66

answers:

3

Hello folks,
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 no use
thankz in advance

+1  A: 

In AppController::beforeFilter() add the following:

$this->Auth->allowedActions = array('display');
bancer
+1  A: 

In 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('*');
}
Leo
Do remember to change this back afterwards! Also don't get caught by allowing login and logout, as iirc they are available by default in the component. Check the book ideally :)
DavidYell
@DY: In the pages controller it shouldn't be an issue as it it there to display public pages that don't fit elsewhere. I should have checked the default - it actually has $this->Auth->allowedActions = array('display'); which should be sufficient.
Leo
A: 

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

Nick
Sorry nick this is used to redirect after successful login right?but thatz not my case
RSK