Skip to content

Commit f2b9aa5

Browse files
Fixed HTTP Status code when ajaxLogin is set
1 parent e36c954 commit f2b9aa5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/Cake/Controller/Component/AuthComponent.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ protected function _unauthenticated(Controller $controller) {
363363
return false;
364364
}
365365
if (!empty($this->ajaxLogin)) {
366+
$controller->response->statusCode(403);
366367
$controller->viewPath = 'Elements';
367368
echo $controller->render($this->ajaxLogin, $this->RequestHandler->ajaxLayout);
368369
$this->_stop();

lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,11 +1106,13 @@ public function testAjaxLogin() {
11061106

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

1109+
$Response = new CakeResponse();
11091110
ob_start();
11101111
$Dispatcher = new Dispatcher();
1111-
$Dispatcher->dispatch(new CakeRequest('/ajax_auth/add'), new CakeResponse(), array('return' => 1));
1112+
$Dispatcher->dispatch(new CakeRequest('/ajax_auth/add'), $Response, array('return' => 1));
11121113
$result = ob_get_clean();
11131114

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

0 commit comments

Comments
 (0)