Thursday, October 29, 2009

RequireSecure Redirect Issues

I put the following code in one of my controllers, trying to force it
to use SSL:

function beforeFilter() {
$this->Security->blackHoleCallback = 'forceSSL';
$this->Security->requireSecure();
}

function forceSSL() {
$this->redirect('https://' . $_SERVER['SERVER_NAME'] . $this->here);
}


But whenever I go to a page using this controller, I get redirected to
my login page with the message "You are not authorized to access that
location."

I am using Auth in my appcontroller. I'm guessing that has something
to do with it. But for the life of me I cannot figure it out.

This is the code in my AppController for Auth:

$this->Auth->fields = array('username' => 'email',
'password' => 'password');
//$this->Auth->loginAction = array('controller' => 'users', 'action'
=> 'login');
$this->Auth->loginRedirect = '/';
$this->Auth->logoutRedirect = '/';
$this->Auth->allow('*');
$this->Auth->loginError = 'Invalid e-mail / password combination.
Please try again';
$this->Auth->autoRedirect = false;

$this->Auth->authorize = 'controller';
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: