Skip to content

Commit

Permalink
Fixed HTTP Status code when ajaxLogin is set
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsteinsland committed Feb 5, 2014
1 parent e36c954 commit f2b9aa5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/Cake/Controller/Component/AuthComponent.php
Expand Up @@ -363,6 +363,7 @@ protected function _unauthenticated(Controller $controller) {
return false;
}
if (!empty($this->ajaxLogin)) {
$controller->response->statusCode(403);
$controller->viewPath = 'Elements';
echo $controller->render($this->ajaxLogin, $this->RequestHandler->ajaxLayout);
$this->_stop();
Expand Down
Expand Up @@ -1106,11 +1106,13 @@ public function testAjaxLogin() {

App::uses('Dispatcher', 'Routing');

$Response = new CakeResponse();
ob_start();
$Dispatcher = new Dispatcher();
$Dispatcher->dispatch(new CakeRequest('/ajax_auth/add'), new CakeResponse(), array('return' => 1));
$Dispatcher->dispatch(new CakeRequest('/ajax_auth/add'), $Response, array('return' => 1));
$result = ob_get_clean();

$this->assertEquals(403, $Response->statusCode());
$this->assertEquals("Ajax!\nthis is the test element", str_replace("\r\n", "\n", $result));
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
}
Expand Down

0 comments on commit f2b9aa5

Please sign in to comment.