From c84b4cf36d270048c5577eb5cb65d626768b4283 Mon Sep 17 00:00:00 2001 From: "renan.saddam" Date: Thu, 13 Aug 2009 13:08:30 -0300 Subject: [PATCH] Changing AuthComponent::deny to accepts same param as AuthComponent::allow, tests added --- cake/libs/controller/components/auth.php | 7 +++++-- .../cases/libs/controller/components/auth.test.php | 11 ++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 19d930545..0ed374f6b 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -591,7 +591,7 @@ class AuthComponent extends Object { * Takes a list of actions in the current controller for which authentication is not required, or * no parameters to allow all actions. * - * @param string $action Controller action name + * @param mixed $action Controller action name or array of actions * @param string $action Controller action name * @param string ... etc. * @return void @@ -612,7 +612,7 @@ class AuthComponent extends Object { /** * Removes items from the list of allowed actions. * - * @param string $action Controller action name + * @param mixed $action Controller action name or array of actions * @param string $action Controller action name * @param string ... etc. * @return void @@ -621,6 +621,9 @@ class AuthComponent extends Object { */ function deny() { $args = func_get_args(); + if (isset($args[0]) && is_array($args[0])) { + $args = $args[0]; + } foreach ($args as $arg) { $i = array_search($arg, $this->allowedActions); if (is_int($i)) { diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 34ddb2955..e6b75a5cf 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -777,7 +777,7 @@ class AuthTest extends CakeTestCase { $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->allow('*'); - $this->Controller->Auth->deny('add'); + $this->Controller->Auth->deny('add', 'camelcase'); $this->Controller->params['action'] = 'delete'; $this->assertTrue($this->Controller->Auth->startup($this->Controller)); @@ -787,6 +787,15 @@ class AuthTest extends CakeTestCase { $this->Controller->params['action'] = 'Add'; $this->assertFalse($this->Controller->Auth->startup($this->Controller)); + + $this->Controller->params['action'] = 'camelCase'; + $this->assertFalse($this->Controller->Auth->startup($this->Controller)); + + $this->Controller->Auth->allow('*'); + $this->Controller->Auth->deny(array('add', 'camelcase')); + + $this->Controller->params['action'] = 'camelCase'; + $this->assertFalse($this->Controller->Auth->startup($this->Controller)); } /**