Allow AuthComponent to deny all actions with single deny() or deny('*')

This commit is contained in:
Daniel Luiz Pakuschewski 2011-10-26 22:07:17 -02:00
parent 1244656595
commit 5246e7dd1d

View file

@ -461,16 +461,20 @@ class AuthComponent extends Component {
*/ */
public function deny($action = null) { public function deny($action = null) {
$args = func_get_args(); $args = func_get_args();
if (isset($args[0]) && is_array($args[0])) { if(empty($args) || $args == array('*')){
$args = $args[0]; $this->allowedActions = array();
} }else{
foreach ($args as $arg) { if (isset($args[0]) && is_array($args[0])) {
$i = array_search($arg, $this->allowedActions); $args = $args[0];
if (is_int($i)) {
unset($this->allowedActions[$i]);
} }
foreach ($args as $arg) {
$i = array_search($arg, $this->allowedActions);
if (is_int($i)) {
unset($this->allowedActions[$i]);
}
}
$this->allowedActions = array_values($this->allowedActions);
} }
$this->allowedActions = array_values($this->allowedActions);
} }
/** /**