From f2b9aa5ca41ed16327793ef7b771840ba1cfc2d2 Mon Sep 17 00:00:00 2001 From: David Steinsland Date: Wed, 5 Feb 2014 16:05:02 +0100 Subject: [PATCH] Fixed HTTP Status code when ajaxLogin is set --- lib/Cake/Controller/Component/AuthComponent.php | 1 + lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index 136707be0..7a4e5fbd2 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -363,6 +363,7 @@ class AuthComponent extends Component { return false; } if (!empty($this->ajaxLogin)) { + $controller->response->statusCode(403); $controller->viewPath = 'Elements'; echo $controller->render($this->ajaxLogin, $this->RequestHandler->ajaxLayout); $this->_stop(); diff --git a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php index e5561580e..54afee5e6 100644 --- a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php @@ -1106,11 +1106,13 @@ class AuthComponentTest extends CakeTestCase { 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']); }