mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-10 05:22:41 +00:00
Refactoring authorization objects to also use settings, it makes them consistent with authenticate objects.
Making actionPath automatically pass into authentication objects. Adding tests.
This commit is contained in:
parent
e34fdde918
commit
0c7f9149ca
3 changed files with 48 additions and 20 deletions
|
@ -91,6 +91,16 @@ class AuthComponent extends Component {
|
|||
*/
|
||||
protected $_authorizeObjects = array();
|
||||
|
||||
/**
|
||||
* A hash mapping legacy properties => to settings passed into Authorize objects.
|
||||
*
|
||||
* @var string
|
||||
* @deprecated Will be removed in 2.1+
|
||||
*/
|
||||
protected $_authorizeLegacyMap = array(
|
||||
'actionPath' => 'actionPath',
|
||||
);
|
||||
|
||||
/**
|
||||
* The name of an optional view element to render when an Ajax request is made
|
||||
* with an invalid or expired session
|
||||
|
@ -499,6 +509,11 @@ class AuthComponent extends Component {
|
|||
if (!method_exists($className, 'authorize')) {
|
||||
throw new CakeException(__('Authorization objects must implement an authorize method.'));
|
||||
}
|
||||
foreach ($this->_authorizeLegacyMap as $old => $new) {
|
||||
if (empty($settings[$new]) && !empty($this->{$old})) {
|
||||
$settings[$new] = $this->{$old};
|
||||
}
|
||||
}
|
||||
$this->_authorizeObjects[] = new $className($this->_Collection->getController(), $settings);
|
||||
}
|
||||
return $this->_authorizeObjects;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue