Permalink
Browse files

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

…allow, tests added
  • Loading branch information...
1 parent 2484245 commit c84b4cf36d270048c5577eb5cb65d626768b4283 @renan renan committed Aug 13, 2009
@@ -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)) {
@@ -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));
}
/**

0 comments on commit c84b4cf

Please sign in to comment.