mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #2781 from davidsteinsland/2.5
Fixed HTTP Status code when ajaxLogin is set
This commit is contained in:
commit
3ca338fe26
2 changed files with 4 additions and 1 deletions
|
@ -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();
|
||||||
|
|
|
@ -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']);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue