Question

I've got a CakePHP site that is stuck in a redirect loop. I've removed every piece of code that does a redirect & I've turned off autoRedirect on the Auth object.

This occurred when I logged out of the site and has persisted even after deleting all cookies and just trying to load the homepage. The index action is in $this->Auth->allow.

I should not, it keeps trying to redirect me to /users/login which then redirect loops. The login action is also in the allowed list

Does anyone have any ideas what could cause this?

Was it helpful?

Solution

Your <cake>/app/app_controller should have a beforeFilter() method with all behaviors of Auth component. One of those behaviors is where to send when a user is not logged in.

you will be looking for something like:

// If cake should redirect automatically or you will do it in the User.login()
$this->Auth->autoRedirect = true; 
// And if the autoRedirect is true, where to redirect
$this->Auth->loginRedirect = '/user/login';

G'luck

OTHER TIPS

This also occurs in CakePHP 1.3 if you add a custom component that extends Component instead of Object.

hey sometimes, if you db connection are wrong,,, the application will be trying connect to the mysql, and will be in looping. So, look allways if the database config are right.

good bye.

I had the same problem exactly, and when I restarted the mySql service the redirect stopped. So add this to your list of things to check.

Well it appears that there are a number of reasons why this could happen in my case i was trying to access

cakeapplication/users/add

and it came out that i was missing

'add'=>'*',

in the permissions array in usersController.php

I recently had this problem and I know not why but it was fixed when I changed (in my AppController beforeFilter() method):

$this->Auth->allow('*');

to

$this->Auth->allow();

Of course then in my subsequent controllers I deny the approriate actions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top