Merge pull request #2781 from davidsteinsland/2.5

Fixed HTTP Status code when ajaxLogin is set
This commit is contained in:
Mark 2014-03-06 12:37:51 +01:00
commit 3ca338fe26
2 changed files with 4 additions and 1 deletions

View file

@ -365,6 +365,7 @@ class AuthComponent extends Component {
return false; return false;
} }
if (!empty($this->ajaxLogin)) { if (!empty($this->ajaxLogin)) {
$controller->response->statusCode(403);
$controller->viewPath = 'Elements'; $controller->viewPath = 'Elements';
echo $controller->render($this->ajaxLogin, $this->RequestHandler->ajaxLayout); echo $controller->render($this->ajaxLogin, $this->RequestHandler->ajaxLayout);
$this->_stop(); $this->_stop();

View file

@ -1106,11 +1106,13 @@ class AuthComponentTest extends CakeTestCase {
App::uses('Dispatcher', 'Routing'); App::uses('Dispatcher', 'Routing');
$Response = new CakeResponse();
ob_start(); ob_start();
$Dispatcher = new Dispatcher(); $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(); $result = ob_get_clean();
$this->assertEquals(403, $Response->statusCode());
$this->assertEquals("Ajax!\nthis is the test element", str_replace("\r\n", "\n", $result)); $this->assertEquals("Ajax!\nthis is the test element", str_replace("\r\n", "\n", $result));
unset($_SERVER['HTTP_X_REQUESTED_WITH']); unset($_SERVER['HTTP_X_REQUESTED_WITH']);
} }