Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changing AuthComponent::deny to accepts same param as AuthComponent::…

…allow, tests added
  • Loading branch information...
commit c84b4cf36d270048c5577eb5cb65d626768b4283 1 parent 2484245
@renan renan authored
View
7 cake/libs/controller/components/auth.php
@@ -591,7 +591,7 @@ function __authType($auth = null) {
* 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 @@ function allow() {
/**
* 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 @@ function allow() {
*/
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)) {
View
11 cake/tests/cases/libs/controller/components/auth.test.php
@@ -777,7 +777,7 @@ function testAllowDenyAll() {
$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 @@ function testAllowDenyAll() {
$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));
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.