Hey Folks,
I'm trying to use the Security component for a simple HTTP
authentication on a single item in my Cake App, and I'm having trouble
getting a proper error message to display upon incorrect login or when
I cancel the login. At the moment, I just a blank page when I would
expected a standard Apache 401 Authorization error screen to appear.
I've traced through the code, and see that $this->redirect is being
trigged from Security::blackHole() as:
$controller->redirect(null, $code, true);
Where $code is set to 401.
Also, the session does not seem to reset between a failed login
attempt, so I don't get prompted for a login screen again until I
delete my authenticated sessions in my browser.
I'm using the code almost exactly as suggested in the Cake Book. In
my app_controller.php :
function beforeFilter() {
// othAuth login stuff that triggers on Cake.admin
// if not admin then.....
$pass = Router::getParam('pass');
$controller = Router::getParam('controller');
# See if there are any pages set to be protected in the
current controller #
$protectedPages = Configure::read('HTTPAuth.'.$controller);
if (!is_array($protectedPages)) {
$protectedPages = array();
}
if (isset($pass[0]) && array_key_exists($pass[0],$protectedPages)) {
$this->Security->loginOptions = array(
'type'=>'basic',
'realm'=>$controller.'/';
);
$password = Configure::read('HTTPAuth.generalLogin.password');
$user = Configure::read('HTTPAuth.generalLogin.username');
$this->Security->loginUsers[$user] = $password;
$this->Security->requireLogin();
}
}
I've doubled checked, and I am getting values for $username and
$password. The prompt works, it's just the error I'm having trouble
making work correctly.
Thanks in advance for any and all help!
-Casey
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---