mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Cleaning up code left over from 1.3. If no black-hole callback is specified Security::blackHole() now throws an exception. Closes #1532
This commit is contained in:
parent
7f0f224c56
commit
fc5a465189
1 changed files with 3 additions and 7 deletions
|
@ -274,7 +274,7 @@ class SecurityComponent extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Black-hole an invalid request with a 404 error or custom callback. If SecurityComponent::$blackHoleCallback
|
* Black-hole an invalid request with a 400 error or custom callback. If SecurityComponent::$blackHoleCallback
|
||||||
* is specified, it will use this callback by executing the method indicated in $error
|
* is specified, it will use this callback by executing the method indicated in $error
|
||||||
*
|
*
|
||||||
* @param Controller $controller Instantiating controller
|
* @param Controller $controller Instantiating controller
|
||||||
|
@ -282,15 +282,11 @@ class SecurityComponent extends Component {
|
||||||
* @return mixed If specified, controller blackHoleCallback's response, or no return otherwise
|
* @return mixed If specified, controller blackHoleCallback's response, or no return otherwise
|
||||||
* @see SecurityComponent::$blackHoleCallback
|
* @see SecurityComponent::$blackHoleCallback
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/components/security-component.html#handling-blackhole-callbacks
|
* @link http://book.cakephp.org/2.0/en/core-libraries/components/security-component.html#handling-blackhole-callbacks
|
||||||
|
* @throws BadRequestException
|
||||||
*/
|
*/
|
||||||
public function blackHole($controller, $error = '') {
|
public function blackHole($controller, $error = '') {
|
||||||
if ($this->blackHoleCallback == null) {
|
if ($this->blackHoleCallback == null) {
|
||||||
$code = 404;
|
throw new BadRequestException(__d('cake_dev', 'The request has been black-holed'));
|
||||||
if ($error == 'login') {
|
|
||||||
$code = 401;
|
|
||||||
$controller->header($this->loginRequest());
|
|
||||||
}
|
|
||||||
return $controller->redirect(null, $code, true);
|
|
||||||
} else {
|
} else {
|
||||||
return $this->_callback($controller, $this->blackHoleCallback, array($error));
|
return $this->_callback($controller, $this->blackHoleCallback, array($error));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue